Commit 4da132d2 authored by Aryan Noshirvani's avatar Aryan Noshirvani

Replace stock Swagger UI with a custom API console

The generic Swagger UI has no concept of "upload audio, get audio back" -
every response was just a raw JSON blob with a download_url string you'd
have to copy elsewhere to actually listen to. Built a small self-contained
console (single HTML file, dark/neon theme matching the Flutter app's
AppTheme) instead:

- AI Remix panel: drag-and-drop up to 5 files, a prompt box, a live
  per-stage progress bar (queued -> planning -> separating -> mixing ->
  mastering -> tagging -> done) that polls GET /remix/{job_id}, and an
  inline <audio> player for the result plus the AI's actual plan
  (target BPM, which stems came from which song).
- Tag & Identify panel: same idea for the single-file /music/upload flow.
- A generic endpoint explorer below both, built dynamically from the
  live /openapi.json (grouped by router tag, expandable "try it" forms
  for path/query params and JSON bodies) so every other route - auth,
  discovery, library, social - is still reachable without hand-writing
  bespoke UI for each.

Same HTTP Basic auth gate as before (verify_docs_auth on the /docs
route); the console's own fetch() calls ride on the browser's cached
Basic Auth for the origin, no extra plumbing needed.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
parent a67fd682
Pipeline #989 passed with stage
in 7 minutes and 2 seconds
import os
import secrets
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.responses import RedirectResponse
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.openapi.utils import get_openapi
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.staticfiles import StaticFiles
......@@ -13,6 +12,8 @@ from src.core.config import DOCS_PASSWORD, DOCS_USERNAME
os.makedirs("/root/antigrav-stax-audio/downloads", exist_ok=True)
os.makedirs("/root/antigrav-stax-audio/temp", exist_ok=True)
CONSOLE_HTML_PATH = os.path.join(os.path.dirname(__file__), "static", "console.html")
docs_security = HTTPBasic()
......@@ -47,9 +48,10 @@ async def root():
return RedirectResponse(url="/docs")
@app.get("/docs", include_in_schema=False)
@app.get("/docs", include_in_schema=False, response_class=HTMLResponse)
async def get_documentation(username: str = Depends(verify_docs_auth)):
return get_swagger_ui_html(openapi_url="/openapi.json", title="Stax API Docs")
with open(CONSOLE_HTML_PATH, "r") as f:
return f.read()
@app.get("/openapi.json", include_in_schema=False)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment