Spaces:
Running on Zero
Running on Zero
Add status endpoint reporting HF token presence
Browse files
app.py
CHANGED
|
@@ -417,6 +417,19 @@ def _nach_wav(pfad):
|
|
| 417 |
return ziel
|
| 418 |
|
| 419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
def vorbereiten_api(key, audio, transkript=None):
|
| 421 |
"""Schritt 1: Audio entgegennehmen und in WAV wandeln.
|
| 422 |
|
|
@@ -598,6 +611,8 @@ with gr.Blocks(title="Sprecher-Analyse API") as demo:
|
|
| 598 |
f"Die App selbst läuft unter **[{FRONTEND}]({FRONTEND})**. "
|
| 599 |
f"Dieses Formular dient nur zu Testzwecken.")
|
| 600 |
key = gr.Textbox(label="Zugangsschlüssel", type="password")
|
|
|
|
|
|
|
| 601 |
with gr.Tab("Analyse"):
|
| 602 |
audio = gr.Audio(sources=["upload", "microphone"], type="filepath",
|
| 603 |
label="Audio")
|
|
|
|
| 417 |
return ziel
|
| 418 |
|
| 419 |
|
| 420 |
+
def status_api(key, request: gr.Request = None):
|
| 421 |
+
"""Meldet, ob die Anfrage mit HF-Token ankommt (GPU-Kontingent-Zuordnung)."""
|
| 422 |
+
if not _pruefe(key):
|
| 423 |
+
return {"ok": False, "fehler": "Ungültiger Zugangsschlüssel."}
|
| 424 |
+
kopf = {}
|
| 425 |
+
try:
|
| 426 |
+
kopf = dict(request.headers) if request is not None else {}
|
| 427 |
+
except Exception:
|
| 428 |
+
pass
|
| 429 |
+
auth = kopf.get("authorization") or kopf.get("Authorization") or ""
|
| 430 |
+
return {"ok": True, "token": auth.lower().startswith("bearer hf_")}
|
| 431 |
+
|
| 432 |
+
|
| 433 |
def vorbereiten_api(key, audio, transkript=None):
|
| 434 |
"""Schritt 1: Audio entgegennehmen und in WAV wandeln.
|
| 435 |
|
|
|
|
| 611 |
f"Die App selbst läuft unter **[{FRONTEND}]({FRONTEND})**. "
|
| 612 |
f"Dieses Formular dient nur zu Testzwecken.")
|
| 613 |
key = gr.Textbox(label="Zugangsschlüssel", type="password")
|
| 614 |
+
gr.Button("Status prüfen").click(status_api, [key], gr.JSON(),
|
| 615 |
+
api_name="status")
|
| 616 |
with gr.Tab("Analyse"):
|
| 617 |
audio = gr.Audio(sources=["upload", "microphone"], type="filepath",
|
| 618 |
label="Audio")
|