-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (28 loc) · 841 Bytes
/
main.py
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
32
33
34
35
36
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from flaskwebgui import FlaskUI
from insightax.api import router as api_router
app = FastAPI()
app.include_router(api_router, prefix="/api")
origins = ['*']
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.mount("/", StaticFiles(directory="./frontend/dist", html=True))
@app.get("/")
async def root():
"""
Redirects to the Web interface.
Returns:
"""
try:
return RedirectResponse(url="/")
except Exception as error:
raise HTTPException(
status_code=HTTP_500_INTERNAL_SERVER_ERROR, detail="Internal Server Error"
) from error