Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,23 +1,31 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
-
|
| 4 |
-
from app.api import api_router
|
| 5 |
-
from app.config import get_settings
|
| 6 |
-
|
| 7 |
-
settings = get_settings()
|
| 8 |
-
|
| 9 |
-
app = FastAPI(
|
| 10 |
-
title=
|
| 11 |
-
version="1.0.0",
|
| 12 |
-
description="LSTM-based stock prediction API for the QuantMind dashboard.",
|
| 13 |
-
)
|
| 14 |
-
|
| 15 |
-
app.add_middleware(
|
| 16 |
-
CORSMiddleware,
|
| 17 |
-
allow_origins=
|
| 18 |
-
allow_credentials=True,
|
| 19 |
-
allow_methods=["*"],
|
| 20 |
-
allow_headers=["*"],
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
+
|
| 4 |
+
from app.api import api_router
|
| 5 |
+
from app.config import get_settings
|
| 6 |
+
|
| 7 |
+
settings = get_settings()
|
| 8 |
+
|
| 9 |
+
app = FastAPI(
|
| 10 |
+
title=settings.app_name,
|
| 11 |
+
version="1.0.0",
|
| 12 |
+
description="LSTM-based stock prediction API for the QuantMind dashboard.",
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
app.add_middleware(
|
| 16 |
+
CORSMiddleware,
|
| 17 |
+
allow_origins=settings.cors_origins,
|
| 18 |
+
allow_credentials=True,
|
| 19 |
+
allow_methods=["*"],
|
| 20 |
+
allow_headers=["*"],
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@app.on_event("startup")
|
| 25 |
+
def startup_event():
|
| 26 |
+
# Fail fast if critical config is missing
|
| 27 |
+
settings.validate()
|
| 28 |
+
print("[Startup] QuantMind backend initialized successfully")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
app.include_router(api_router)
|