tebrox / main.py
understanding's picture
Update main.py
ffdffe9 verified
raw
history blame
959 Bytes
# main.py
import logging
import asyncio
from fastapi import FastAPI
from fastapi.responses import JSONResponse
import uvicorn
import bot # import your bot.py (it already starts Dispatcher there)
import db_utils
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
app = FastAPI()
@app.on_event("startup")
async def on_startup():
logger.info("Starting bot polling in background...")
asyncio.create_task(bot.run_polling())
@app.get("/health")
async def health_check():
return JSONResponse({
"status": "ok",
"workers": bot.config.CONCURRENT_WORKERS,
"active_batches": len(bot.BATCH_JOBS),
"active_users": await db_utils.get_all_active_user_ids_db(),
})
@app.get("/")
async def root_page():
return JSONResponse({
"message": "πŸš€ TeraBox Bot is running.",
"endpoints": ["/health"],
})
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=7860)