path updated

This commit is contained in:
Philip Cheung 2024-10-07 17:17:06 +08:00
parent 2e11c54960
commit 4f29c98daf
1 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import sentry_sdk import sentry_sdk
import os
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
@ -18,8 +19,12 @@ app = FastAPI(
title=settings.PROJECT_NAME, title=settings.PROJECT_NAME,
openapi_url=f"{settings.API_V1_STR}/openapi.json", openapi_url=f"{settings.API_V1_STR}/openapi.json",
generate_unique_id_function=custom_generate_unique_id, generate_unique_id_function=custom_generate_unique_id,
) )
app.mount("/static", StaticFiles(directory="static"), name="static") # app.mount("/static", StaticFiles(directory="static"), name="static")
script_dir = os.path.dirname(__file__)
st_abs_file_path = os.path.join(script_dir, "static/")
app.mount("/static", StaticFiles(directory=st_abs_file_path), name="static")
# Set all CORS enabled origins # Set all CORS enabled origins
if settings.BACKEND_CORS_ORIGINS: if settings.BACKEND_CORS_ORIGINS:
app.add_middleware( app.add_middleware(