Spaces:
Sleeping
Sleeping
Download app/main.py from Hamza4100/AI-Datrix-Backend: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/Hamza4100/AI-Datrix-Backend/resolve/main/app/main.py
- Command line
-
hf download hf://spaces/Hamza4100/AI-Datrix-Backend/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Hamza4100/AI-Datrix-Backend/resolve/main/app/main.py
1.5 kB
| 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) | |
| async def root(): | |
| return {"message": "Hello"} | |
| async def health_check(): | |
| return {"status": "ok", "message": "System is healthy"} | |