43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
"""Platform - Main Application."""
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
from app.settings import get_settings
|
|
from app.core.database import init_db
|
|
from app.api.v1 import auth, users, roles, modules, health
|
|
|
|
app = FastAPI(
|
|
title=get_settings().APP_NAME,
|
|
version=get_settings().APP_VERSION,
|
|
description="Platform - Module Management System",
|
|
openapi_url="/openapi.json",
|
|
)
|
|
|
|
# CORS
|
|
cors_origins = get_settings().APP_CORS_ORIGINS.split(",")
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Routes
|
|
app.include_router(health.router, prefix="/api/v1")
|
|
app.include_router(auth.router, prefix="/api/v1")
|
|
app.include_router(users.router, prefix="/api/v1")
|
|
app.include_router(roles.router, prefix="/api/v1")
|
|
app.include_router(modules.router, prefix="/api/v1")
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def startup():
|
|
init_db()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run("app.main:app", host="0.0.0.0", port=9000, reload=True)
|