Spaces:
Sleeping
Sleeping
File size: 1,499 Bytes
8de5584 | 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import sys
import io
# Force console standard streams to use UTF-8 to prevent Windows CP1252/charmap encoding crashes
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8")
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.config import settings
from app.schemas import MessageResponse, HealthResponse
from app.routes import (
auth,
upload,
ocr,
text_cleaning,
llm_extraction,
embeddings,
search,
chatbot,
analytics,
)
app = FastAPI(
title=settings.APP_NAME,
description="AI-Based Pathology Report Management",
debug=settings.DEBUG,
)
# Allow frontend (React/Flutter/Mobile) to call this API
app.add_middleware(
CORSMiddleware,
allow_origin_regex="https?://.*",
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(auth.router)
app.include_router(upload.router)
app.include_router(ocr.router)
app.include_router(text_cleaning.router)
app.include_router(llm_extraction.router)
app.include_router(embeddings.router)
app.include_router(search.router)
app.include_router(chatbot.router)
app.include_router(analytics.router)
@app.get("/", response_model=MessageResponse)
async def root():
return {"message": "Hello"}
@app.get("/health", response_model=HealthResponse)
async def health_check():
return {"status": "ok", "message": "System is healthy"}
|