feat: change API router structure
This commit is contained in:
18
main.py
18
main.py
@@ -10,6 +10,7 @@ from analysis import analysis_router
|
||||
|
||||
|
||||
app = FastAPI(title="cutt")
|
||||
api_router = APIRouter(prefix="/api")
|
||||
origins = [
|
||||
"*",
|
||||
"http://localhost",
|
||||
@@ -80,7 +81,16 @@ def submit_chemistry(chemistry: Chemistry):
|
||||
session.commit()
|
||||
|
||||
|
||||
app.include_router(player_router)
|
||||
app.include_router(team_router)
|
||||
app.include_router(analysis_router)
|
||||
app.mount("/", StaticFiles(directory="dist", html=True), name="site")
|
||||
class SPAStaticFiles(StaticFiles):
|
||||
async def get_response(self, path: str, scope):
|
||||
response = await super().get_response(path, scope)
|
||||
if response.status_code == 404:
|
||||
response = await super().get_response(".", scope)
|
||||
return response
|
||||
|
||||
|
||||
api_router.include_router(player_router)
|
||||
api_router.include_router(team_router)
|
||||
api_router.include_router(analysis_router)
|
||||
app.include_router(api_router)
|
||||
app.mount("/", SPAStaticFiles(directory="dist", html=True), name="site")
|
||||
|
||||
Reference in New Issue
Block a user