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