Spaces:
Runtime error
Runtime error
| from __future__ import annotations | |
| import asyncio | |
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from app.config import load_config | |
| from app.cf_api import CFClient | |
| from bot.client import build_bot | |
| from bot.handlers import register_handlers | |
| cfg = load_config() | |
| cf = CFClient(cfg.WORKER1_URL, cfg.WORKER2_URL, cfg.BOT_BACKEND_KEY, cfg.HF_API_KEY) | |
| bot = build_bot(cfg) | |
| async def lifespan(app: FastAPI): | |
| # start bot | |
| await register_handlers(bot, cfg, cf) | |
| await bot.start() | |
| yield | |
| # stop bot | |
| await bot.stop() | |
| await cf.close() | |
| app = FastAPI(lifespan=lifespan) | |
| async def root(): | |
| return { | |
| "ok": True, | |
| "service": "yt-uploader-bot", | |
| "bot_username": cfg.BOT_USERNAME, | |
| } | |
| async def health(): | |
| return {"ok": True} |