From 8fea6e4be4a61cd2bfcb310166fbe6b2541b9ff4 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Thu, 21 May 2026 20:45:15 +0800 Subject: video and blog --- main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'main.py') diff --git a/main.py b/main.py index 9af3a54..f8e56df 100644 --- a/main.py +++ b/main.py @@ -17,6 +17,7 @@ TURNSTILE_SECRET = getenv("CLOUDFLARE_TURNSTILE_SECRET").encode("utf-8") origins = [ "http://localhost", + "http://localhost:9091", "https://altafcreator.com", "https://backend.altafcreator.com" ] @@ -97,4 +98,23 @@ def blogpost_redirect(blogpost: str): status_code=301 ) + +@app.get("/video/{video_name}/") +def video_page(video_name: str): + status, html = pages.render_video(video_name) + + if status == 200: + return fastapi.responses.Response(content=html, media_type="text/html", status_code=200) + else: + raise fastapi.HTTPException(status_code=status, detail="Blogpost doesn't exist.") + + +@app.get("/video/{video_name}", include_in_schema=False) +def video_page_redirect(video_name: str): + return fastapi.responses.RedirectResponse( + url=f"/video/{video_name}/", + status_code=301 + ) + + app.mount("/", fastapi.staticfiles.StaticFiles(directory="./www/", html=True), name="static") -- cgit v1.2.3