This commit is contained in:
Philip Cheung 2024-10-07 18:02:29 +08:00
parent 8c59dda61f
commit d9b88af994
1 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import sentry_sdk import sentry_sdk
import os from pathlib import Path
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.routing import APIRoute from fastapi.routing import APIRoute
from starlette.middleware.cors import CORSMiddleware from starlette.middleware.cors import CORSMiddleware
@ -22,9 +22,15 @@ app = FastAPI(
) )
# app.mount("/static", StaticFiles(directory="static"), name="static") # app.mount("/static", StaticFiles(directory="static"), name="static")
static_file_abspath = os.path.join(os.path.dirname(__file__), "static")
app.mount("/static", StaticFiles(directory=static_file_abspath), name="static")
current_file = Path(__file__)
current_file_dir = current_file.parent
project_root = current_file_dir.parent
project_root_absolute = project_root.resolve()
static_root_absolute = project_root_absolute / "static"
app.mount("/static", static_root_absolute, name="static")
# Set all CORS enabled origins # Set all CORS enabled origins
if settings.BACKEND_CORS_ORIGINS: if settings.BACKEND_CORS_ORIGINS: