|
Download ideas/038-tiny-paste.md from broadfield/things-we-should-build: direct link, hf CLI and curl.
- Browser
- Download file 2.31 kB
-
https://huggingface.co/datasets/broadfield/things-we-should-build/resolve/main/ideas/038-tiny-paste.md
- Command line
-
hf download hf://datasets/broadfield/things-we-should-build/ideas/038-tiny-paste.md
-
curl -L -o 038-tiny-paste.md https://huggingface.co/datasets/broadfield/things-we-should-build/resolve/main/ideas/038-tiny-paste.md
2.31 kB
038 · Tiny Paste
title: Tiny Paste — a 10-line pastebin / key-value store, backed by datasets-you-own, 100% free forever status: MVP + live license: MIT
why
HF gives hobbyists something no other free host does: an authenticated LFS-backed key-value store in the form of datasets. Tiny Paste wraps that in a human API: paste("hello") → URL; get(url) → text. No server, no DB, no bill — just a repo, a token, and the Hub API. One small Gradio app can give every user of any Space a "save this" button whose storage costs $0.
what
- Static-to-Gradio paste page with two modes:
- Read (no auth): paste a
https://huggingface.co/datasets/{you}/tiny-paste/resolve/main/p/abc123.txtURL → text. - Write (token in localStorage):
POSTviahf_upload_repo_file, key = random 6 chars.
- Read (no auth): paste a
- Optional expiry: cron/dataset hook clears keys older than N days.
- Namespace per user: any dataset id works (
{user}/{anything}for keyspace separation).
plan
- Gradio (CPU, free) with
gr.Textboxin/out; read viarequeststo resolve URL. - Write impl: call the Hub upload API with a stored token.
- TTL via
last_seenrepo file + periodic cleanup (#049 cron). - Ship; also expose an HTTP API so other Spaces can use it as their scratch storage.
code
# tiny_paste.py — read/write through the Hub API
import os, random, string, requests
BASE = "https://huggingface.co/datasets/{repo}/resolve/main/p"
def read(key: str) -> str:
url = f"{BASE}/{key}.txt"
r = requests.get(url)
return r.text if r.ok else f"(missing: {key})"
def write(repo: str, token: str, text: str) -> str:
key = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
api = f"https://huggingface.co/api/datasets/{repo}/upload"
r = requests.post(api, headers={"Authorization": f"Bearer {token}"},
json={"path": f"p/{key}.txt", "content": text, "commitMessage": f"paste {key}"})
return f"https://huggingface.co/datasets/{repo}/resolve/main/p/{key}.txt" if r.ok else r.text
next
- Signed URLs: HMAC key so only owners can list/delete.
- Big blobs via LFS (>50MB) with progress bars.
- Namespace the whole things-we-should-build suite: "save my filter settings" for every Space here, backed by one dataset.