60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
"""
|
|
Admin Edu-Space - FastAPI Core Application (Principio 11)
|
|
High-performance ASGI server with modular routers, Pydantic schemas,
|
|
OpenAPI /docs documentation and zero-regression WSGI bridge.
|
|
"""
|
|
from fastapi import FastAPI, Request, status
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
from a2wsgi import WSGIMiddleware
|
|
|
|
from app import __version__
|
|
from database import get_flask_app
|
|
|
|
# Import modular FastAPI routers
|
|
from routers.version import version_router
|
|
from routers.auth import auth_router
|
|
from routers.classrooms import classrooms_router
|
|
from routers.reservations import reservations_router
|
|
from routers.students import students_router
|
|
from routers.dashboard import dashboard_router
|
|
from routers.optimizer import optimizer_router, genetic_router
|
|
|
|
# Initialize FastAPI Application
|
|
app = FastAPI(
|
|
title="Admin Edu-Space REST API",
|
|
description="Plataforma de gestión de espacios áulicos, sincronización académica y optimización inteligente.",
|
|
version=__version__,
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
openapi_url="/openapi.json"
|
|
)
|
|
|
|
# CORS Middleware configuration
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Register high-performance FastAPI Routers
|
|
app.include_router(version_router)
|
|
app.include_router(auth_router)
|
|
app.include_router(classrooms_router)
|
|
app.include_router(reservations_router)
|
|
app.include_router(students_router)
|
|
app.include_router(dashboard_router)
|
|
app.include_router(optimizer_router)
|
|
app.include_router(genetic_router)
|
|
|
|
# Mount zero-regression WSGI bridge for remaining legacy routes and admin modules
|
|
flask_app = get_flask_app()
|
|
app.mount("/", WSGIMiddleware(flask_app))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run("main:app", host="0.0.0.0", port=5000, reload=True)
|