35 lines
935 B
Python
35 lines
935 B
Python
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.routes import health, secrets
|
|
from app.core.config import settings
|
|
from app.db.session import engine
|
|
from app.models import base
|
|
|
|
# Create database tables if they don't exist
|
|
base.Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME,
|
|
description="One-time Secret Sharing Service API",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# Add CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(health.router, tags=["health"])
|
|
app.include_router(secrets.router, prefix="/api/v1", tags=["secrets"])
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |