diff options
| author | altaf-creator <dev@altafcreator.com> | 2026-05-21 20:45:15 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2026-05-21 20:45:15 +0800 |
| commit | 8fea6e4be4a61cd2bfcb310166fbe6b2541b9ff4 (patch) | |
| tree | 3e144c0033200ef792b6e4284ac2789d77b18ccb /main.py | |
| parent | 39c92cd0c75193465ddc7b96e9d8bbe23dff795c (diff) | |
video and blog
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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") |
