Initial commit: Freepik REST API
FastAPI async wrapper for Freepik cloud AI API supporting image generation (Mystic, Flux Dev/Pro, SeedReam), video generation (Kling, MiniMax, Seedance), image editing (upscale, relight, style transfer, expand, inpaint), and utilities (background removal, classifier, audio isolation). Includes async task tracking with polling, Docker containerization, and Gitea CI/CD workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
42
app/main.py
Normal file
42
app/main.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.routers import image_editing, image_generation, system, tasks, utilities, video_generation
|
||||
from app.services import file_manager, freepik_client
|
||||
from app.services.webhook import router as webhook_router
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s %(levelname)s %(name)s: %(message)s',
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
logger.info('Starting Freepik API...')
|
||||
file_manager.ensure_directories()
|
||||
await freepik_client.create_client()
|
||||
logger.info('Freepik API ready')
|
||||
yield
|
||||
logger.info('Shutting down...')
|
||||
await freepik_client.close_client()
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title='Freepik API',
|
||||
version='1.0.0',
|
||||
description='REST API wrapping Freepik cloud AI services',
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
app.include_router(image_generation.router)
|
||||
app.include_router(video_generation.router)
|
||||
app.include_router(image_editing.router)
|
||||
app.include_router(utilities.router)
|
||||
app.include_router(utilities.icon_router)
|
||||
app.include_router(tasks.router)
|
||||
app.include_router(system.router)
|
||||
app.include_router(webhook_router)
|
||||
Reference in New Issue
Block a user