Spaces:
Running
Running
File size: 1,593 Bytes
3f61e65 744003f 3f61e65 031bdcc 3f61e65 031bdcc 3f61e65 22d5408 3f61e65 744003f 3aa96ee 3f61e65 031bdcc 3f61e65 031bdcc |
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 60 61 |
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv
import os
from app.api import beta, admin, generator
from app.core.config import settings
from app.core.database import init_db, engine, Base
# Load environment variables
load_dotenv()
# Create FastAPI app
app = FastAPI(
title="Synthex API",
description="API for generating synthetic medical records",
version="1.0.0",
)
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=[
"http://localhost:3000",
"http://localhost:8000",
"https://synthex.vercel.app",
"https://theaniketgiri-synthex.hf.space"
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Initialize database on startup
@app.on_event("startup")
async def startup_event():
init_db()
# Root endpoint
@app.get("/")
async def root():
return {
"name": "Synthex API",
"version": "1.0.0",
"description": "API for generating synthetic medical records",
"docs_url": "/docs",
"redoc_url": "/redoc"
}
# Health check endpoint
@app.get("/health")
async def health_check():
return {"status": "healthy"}
# Import and include routers
app.include_router(beta.router, prefix="/api/beta", tags=["beta"])
app.include_router(admin.router, prefix="/api/admin", tags=["admin"])
app.include_router(generator.router, prefix="/api/generator", tags=["generator"])
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |