add middlewares (uvicorn)
This commit is contained in:
parent
e8d075a85f
commit
1d8748e63a
1 changed files with 24 additions and 24 deletions
|
@ -33,36 +33,36 @@ app = FastAPI(
|
||||||
|
|
||||||
app.include_router(main_router)
|
app.include_router(main_router)
|
||||||
|
|
||||||
|
if SETTINGS.production_mode:
|
||||||
|
# Mount frontend in production mode
|
||||||
|
app.mount(
|
||||||
|
path="/",
|
||||||
|
app=StaticFiles(
|
||||||
|
directory="/html",
|
||||||
|
html=True,
|
||||||
|
),
|
||||||
|
name="frontend",
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Allow CORS in debug mode
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=[
|
||||||
|
"*",
|
||||||
|
],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
expose_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""
|
"""
|
||||||
If the `main` script is run, `uvicorn` is used to run the app.
|
If the `main` script is run, `uvicorn` is used to run the app.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if SETTINGS.production_mode:
|
|
||||||
# Mount frontend in production mode
|
|
||||||
app.mount(
|
|
||||||
path="/",
|
|
||||||
app=StaticFiles(
|
|
||||||
directory="/html",
|
|
||||||
html=True,
|
|
||||||
),
|
|
||||||
name="frontend",
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Allow CORS in debug mode
|
|
||||||
app.add_middleware(
|
|
||||||
CORSMiddleware,
|
|
||||||
allow_origins=[
|
|
||||||
"*",
|
|
||||||
],
|
|
||||||
allow_credentials=True,
|
|
||||||
allow_methods=["*"],
|
|
||||||
allow_headers=["*"],
|
|
||||||
expose_headers=["*"],
|
|
||||||
)
|
|
||||||
|
|
||||||
if webdav_check():
|
if webdav_check():
|
||||||
uvicorn_run(
|
uvicorn_run(
|
||||||
app="ovdashboard_api.main:app",
|
app="ovdashboard_api.main:app",
|
||||||
|
|
Loading…
Reference in a new issue