synthex / main.py
theaniketgiri's picture
aniket
22d5408
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)