57 lines
1.2 KiB
Python
57 lines
1.2 KiB
Python
"""
|
|
MPR FastAPI Application
|
|
|
|
Main entry point for the REST API.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Add project root to path
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
# Initialize Django before importing models
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mpr.settings")
|
|
|
|
import django
|
|
|
|
django.setup()
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from api.routes import assets_router, jobs_router, presets_router, system_router
|
|
|
|
app = FastAPI(
|
|
title="MPR API",
|
|
description="Media Processor REST API",
|
|
version="0.1.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://mpr.local.ar", "http://localhost:5173"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Routes - all under /api prefix
|
|
app.include_router(system_router, prefix="/api")
|
|
app.include_router(assets_router, prefix="/api")
|
|
app.include_router(presets_router, prefix="/api")
|
|
app.include_router(jobs_router, prefix="/api")
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
"""API root."""
|
|
return {
|
|
"name": "MPR API",
|
|
"version": "0.1.0",
|
|
"docs": "/docs",
|
|
}
|