PhotosAPI/extensions/pages.py

32 lines
1010 B
Python
Raw Normal View History

2022-12-20 16:34:47 +02:00
from os import path
from modules.app import app
from fastapi.responses import HTMLResponse, Response
2023-03-12 15:59:13 +02:00
2022-12-20 16:34:47 +02:00
@app.get("/pages/matter.css", include_in_schema=False)
async def page_matter():
with open(path.join("pages", "matter.css"), "r", encoding="utf-8") as f:
output = f.read()
return Response(content=output)
2023-03-12 15:59:13 +02:00
2022-12-20 16:34:47 +02:00
@app.get("/pages/{page}/{file}", include_in_schema=False)
2023-03-12 15:59:13 +02:00
async def page_assets(page: str, file: str):
2022-12-20 16:34:47 +02:00
with open(path.join("pages", page, file), "r", encoding="utf-8") as f:
output = f.read()
return Response(content=output)
2023-03-12 15:59:13 +02:00
2022-12-20 16:34:47 +02:00
@app.get("/", include_in_schema=False)
async def page_home():
with open(path.join("pages", "home", "index.html"), "r", encoding="utf-8") as f:
output = f.read()
return HTMLResponse(content=output)
2023-03-12 15:59:13 +02:00
2022-12-20 16:34:47 +02:00
@app.get("/register", include_in_schema=False)
async def page_register():
with open(path.join("pages", "register", "index.html"), "r", encoding="utf-8") as f:
output = f.read()
2023-03-12 15:59:13 +02:00
return HTMLResponse(content=output)