serve pages, too

This commit is contained in:
boyska 2020-12-15 15:09:33 +01:00
parent 1965c19bc4
commit 97d6e65bb8

View file

@ -5,8 +5,8 @@ import os
import unicodedata
from datetime import datetime
from fastapi import FastAPI, HTTPException, Response
from fastapi.responses import RedirectResponse
from fastapi import FastAPI, HTTPException, Request, Response
from fastapi.responses import FileResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from .cli import common_pre
@ -299,9 +299,13 @@ def home():
return RedirectResponse("/new.html")
for page in ("new.html", "old.html", "archive.html"):
# route f"/{page}" → get_config()["STATIC_PAGES"] + page
pass
@app.route("/new.html")
@app.route("/old.html")
@app.route("/archive.html")
def serve_pages(request: Request):
page = request.url.path[1:]
fpath = os.path.join(get_config()["STATIC_PAGES"], page)
return FileResponse(fpath)
if __name__ == "__main__":