Spaces:
Running
Running
Upload webapp/app.py with huggingface_hub
Browse files- webapp/app.py +0 -22
webapp/app.py
CHANGED
|
@@ -321,28 +321,6 @@ def _persist_subscriber(email: str, ts: str) -> None:
|
|
| 321 |
pass
|
| 322 |
|
| 323 |
|
| 324 |
-
@app.route("/_diag")
|
| 325 |
-
def _diag():
|
| 326 |
-
import io
|
| 327 |
-
tok = os.environ.get("HF_TOKEN")
|
| 328 |
-
out = [f"HF_TOKEN present: {bool(tok)}", f"len: {len(tok) if tok else 0}"]
|
| 329 |
-
try:
|
| 330 |
-
from huggingface_hub import HfApi
|
| 331 |
-
out.append("huggingface_hub import: OK")
|
| 332 |
-
if tok:
|
| 333 |
-
try:
|
| 334 |
-
HfApi(token=tok).upload_file(
|
| 335 |
-
path_or_fileobj=io.BytesIO(b"diag,now\n"),
|
| 336 |
-
path_in_repo="emails/_diag.csv",
|
| 337 |
-
repo_id=SUBSCRIBERS_DATASET, repo_type="dataset")
|
| 338 |
-
out.append("dataset write: OK")
|
| 339 |
-
except Exception as e:
|
| 340 |
-
out.append(f"dataset write FAILED: {type(e).__name__}: {str(e)[:200]}")
|
| 341 |
-
except Exception as e:
|
| 342 |
-
out.append(f"hub import FAILED: {type(e).__name__}: {e}")
|
| 343 |
-
return "<pre>" + escape("\n".join(out)) + "</pre>"
|
| 344 |
-
|
| 345 |
-
|
| 346 |
@app.route("/subscribe", methods=["POST"])
|
| 347 |
def subscribe():
|
| 348 |
email = (request.form.get("email") or "").strip().lower()
|
|
|
|
| 321 |
pass
|
| 322 |
|
| 323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
@app.route("/subscribe", methods=["POST"])
|
| 325 |
def subscribe():
|
| 326 |
email = (request.form.get("email") or "").strip().lower()
|