Spaces:
Running
Running
| """FastAPI entrypoint for Hugging Face Spaces and local development.""" | |
| from __future__ import annotations | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app.api.routes import router | |
| from app.core.config import settings | |
| app = FastAPI( | |
| title=settings.app_name, | |
| version="0.1.0", | |
| description="Unified A-share market data API with source fallback and database caching.", | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=list(settings.cors_origins), | |
| allow_credentials="*" not in settings.cors_origins, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| def root(): | |
| return { | |
| "ok": True, | |
| "name": settings.app_name, | |
| "docs": "/docs", | |
| "catalog": f"{settings.api_prefix}/catalog", | |
| } | |
| def health(): | |
| return {"ok": True, "version": "v23-ai-search-hub", "commit": "pending"} | |
| app.include_router(router, prefix=settings.api_prefix) | |