Spaces:
Sleeping
Sleeping
File size: 981 Bytes
cee18f7 a03bb33 cee18f7 a03bb33 2256a50 a03bb33 167589c b43c48c 2256a50 a03bb33 2256a50 167589c e3362fc a03bb33 0963fdc a03bb33 e67ec6b 443e629 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | import sys
import os
# Fix Windows console unicode errors when printing emojis
if sys.platform == 'win32':
sys.stdout.reconfigure(encoding='utf-8')
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from core.worker import start_worker
from core.database import db_manager
from routers import audio, status, admin, public_api
app = FastAPI(title="Stemify AI API")
# Allow CORS for the Next.js frontend
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Fail any tasks that were stuck in memory during a server restart
db_manager.fail_stuck_tasks()
# Start global worker thread
start_worker()
# Include Routers
app.include_router(audio.router)
app.include_router(status.router)
app.include_router(admin.router)
app.include_router(public_api.router)
@app.get("/")
async def root():
return {"status": "ok", "service": "Stemify AI Backend API"}
|