Fundamental_Analysis/backend/app/main.py
xucheng ff7dc0c95a feat(backend): introduce DataManager and multi-provider; analysis orchestration; streaming endpoints; remove legacy tushare_client; enhance logging
feat(frontend): integrate Prisma and reports API/pages

chore(config): add data_sources.yaml; update analysis-config.json

docs: add 2025-11-03 dev log; update user guide

scripts: enhance dev.sh; add tushare_legacy_client

deps: update backend and frontend dependencies
2025-11-03 21:48:08 +08:00

57 lines
1.7 KiB
Python

"""
FastAPI application entrypoint
"""
import logging
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.core.config import settings
from app.routers.config import router as config_router
from app.routers.financial import router as financial_router
# Configure logging to ensure our app logs show up in development
import sys
# Force our logging configuration to override uvicorn's
class ForcefulHandler(logging.Handler):
def emit(self, record):
# Force output to stdout regardless of uvicorn's configuration
print(f"[APP] {record.getMessage()}", file=sys.stdout, flush=True)
# Set up our forceful handler for data providers
forceful_handler = ForcefulHandler()
forceful_handler.setLevel(logging.DEBUG)
# Configure data providers logger with forceful output
data_providers_logger = logging.getLogger('app.data_providers')
data_providers_logger.setLevel(logging.DEBUG)
data_providers_logger.addHandler(forceful_handler)
# Also set up for the main app logger
app_logger = logging.getLogger('app')
app_logger.setLevel(logging.INFO)
app_logger.addHandler(forceful_handler)
# Ensure our handlers are not suppressed
data_providers_logger.propagate = False
app_logger.propagate = False
app = FastAPI(title=settings.APP_NAME, version=settings.APP_VERSION)
# CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Routers
app.include_router(config_router, prefix=f"{settings.API_V1_STR}/config", tags=["config"])
app.include_router(financial_router, prefix=f"{settings.API_V1_STR}/financials", tags=["financials"])
@app.get("/")
async def root():
return {"status": "ok", "name": settings.APP_NAME, "version": settings.APP_VERSION}