diff options
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") |
