# main.py import uvicorn from fastapi import FastAPI from fastapi.responses import HTMLResponse import logging import asyncio import bot # import your bot.py file app = FastAPI() @app.on_event("startup") async def startup_event(): logging.basicConfig(level=logging.INFO) logging.info("Starting bot polling in background...") asyncio.create_task(bot.run_bot()) @app.get("/health") def health(): return {"status": "ok"} @app.get("/") def home(): active_workers = bot.config.CONCURRENT_WORKERS running_batches = len(bot.BATCH_JOBS) queued_tasks = bot.TASK_QUEUE.qsize() html = f"""
Bot Username: {bot.bot_username or 'Unknown'}
Active Workers: {active_workers}
Running Batches: {running_batches}
Queued Tasks: {queued_tasks}
Health: /health
""" return HTMLResponse(content=html) if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=7860)