File size: 1,108 Bytes
888cc54 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import uvicorn
from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
# Replace ["*"] with the appropriate list of allowed origins
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.mount("/static", StaticFiles(directory="static", html=True), name="static")
templates = Jinja2Templates(directory="static")
@app.get("/{path_name:path}", response_class=HTMLResponse, tags=["Frontend"])
async def catch_all(request: Request, path_name: str):
return templates.TemplateResponse("index.html", {"request": request})
if __name__ == "__main__":
# uvicorn.run("front_end:app", host="0.0.0.0", port=443, reload=False)
uvicorn.run("front_end:app", host="0.0.0.0", port=443, reload=False,
ssl_keyfile="ssl/private.pem",
ssl_certfile="ssl/certificate.crt")
|