47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
"""FastAPI application entry point."""
|
|
|
|
import asyncio
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from backend.config import settings
|
|
from backend.api import upload, split, status, download
|
|
from backend.api.websocket import router as websocket_router
|
|
from backend.services import progress_publisher # Import the module
|
|
|
|
app = FastAPI(
|
|
title="Audio Splitter Web API",
|
|
description="Web interface for splitting audio files using a tracklist",
|
|
version="0.1.0",
|
|
)
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.allow_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Store the main event loop in the progress_publisher module
|
|
# This avoids a circular import
|
|
progress_publisher.MAIN_LOOP = asyncio.get_running_loop()
|
|
|
|
# Include routers
|
|
app.include_router(upload.router)
|
|
app.include_router(split.router)
|
|
app.include_router(status.router)
|
|
app.include_router(download.router)
|
|
app.include_router(websocket_router)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"status": "ok", "service": "Audio Splitter Web API"}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "healthy"}
|