| from fastapi import FastAPI |
| from fastapi.middleware.cors import CORSMiddleware |
| import uvicorn |
| from datetime import datetime |
| from routers import video, files, presets |
| from init_defaults import init_all_defaults |
| import os |
|
|
| |
| init_all_defaults() |
|
|
| |
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| UPLOAD_BASE_DIR = os.path.join(BASE_DIR, "temp_videos") |
| ORIGINALS_DIR = os.path.join(UPLOAD_BASE_DIR, "originals") |
| PROCESSED_DIR = os.path.join(UPLOAD_BASE_DIR, "processed") |
| AUDIO_DIR = os.path.join(UPLOAD_BASE_DIR, "audio") |
| TEMP_DIR = os.path.join(UPLOAD_BASE_DIR, "temp") |
|
|
| |
| for directory in [UPLOAD_BASE_DIR, ORIGINALS_DIR, PROCESSED_DIR, AUDIO_DIR, TEMP_DIR]: |
| os.makedirs(directory, exist_ok=True) |
|
|
| app = FastAPI( |
| title="Video Processing API", |
| description="Simple API for video processing - optimized for n8n automation", |
| version="1.0.0" |
| ) |
|
|
| |
| app.add_middleware( |
| CORSMiddleware, |
| allow_origins=["*"], |
| allow_credentials=True, |
| allow_methods=["*"], |
| allow_headers=["*"], |
| ) |
|
|
| |
| app.include_router(video.router, prefix="/api/video", tags=["Video"]) |
| app.include_router(files.router, prefix="/api/files", tags=["Files"]) |
| app.include_router(presets.router, prefix="/api/presets", tags=["Presets"]) |
|
|
| |
|
|
| @app.get("/") |
| async def root(): |
| return { |
| "message": "Video Processing API", |
| "version": "1.0.0", |
| "timestamp": datetime.now().isoformat() |
| } |
|
|
| @app.get("/health") |
| async def health_check(): |
| return { |
| "status": "healthy", |
| "timestamp": datetime.now().isoformat() |
| } |
|
|
| if __name__ == "__main__": |
| uvicorn.run("main:app", host="0.0.0.0", port=7860, reload=True) |