File size: 969 Bytes
5c9b605
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f403cbc
5c9b605
 
 
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
37
38
39
40
41
42
43
"""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=["*"],
)


@app.get("/")
def root():
    return {
        "ok": True,
        "name": settings.app_name,
        "docs": "/docs",
        "catalog": f"{settings.api_prefix}/catalog",
    }


@app.get("/health")
def health():
    return {"ok": True, "version": "v23-ai-search-hub", "commit": "pending"}


app.include_router(router, prefix=settings.api_prefix)