# main.py import os import logging import asyncio from fastapi import FastAPI from fastapi.responses import HTMLResponse import uvicorn from bot import bot, setup_dispatcher, TASK_QUEUE, BATCH_JOBS # Setup logging logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", ) app = FastAPI( title="Terabox Bot Admin", description="Web interface for checking Terabox Bot status.", version="1.0.0", ) dp = setup_dispatcher() @app.on_event("startup") async def on_startup(): logging.info("Starting bot polling in background...") asyncio.create_task(dp.start_polling(bot)) # Routes @app.get("/", response_class=HTMLResponse) async def root(): return """ Terabox Bot - Admin Panel

🚀 Terabox Bot is running!

Endpoints:

""" @app.get("/health") async def health(): return {"status": "ok", "message": "Bot is healthy!"} @app.get("/status", response_class=HTMLResponse) async def status(): html = "

📊 Terabox Bot - Current Status

" html += f"

Pending queue size: {TASK_QUEUE.qsize()}

" if not BATCH_JOBS: html += "

✅ No active batches.

" else: html += "" return html # Run with uvicorn if __name__ == "__main__": port = int(os.getenv("PORT", 7860)) # HuggingFace prefers PORT env sometimes uvicorn.run("main:app", host="0.0.0.0", port=port, reload=False)