serve pages, too
This commit is contained in:
parent
1965c19bc4
commit
97d6e65bb8
1 changed files with 9 additions and 5 deletions
|
@ -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__":
|
||||
|
|
Loading…
Reference in a new issue