tebrox / main.py
understanding's picture
Update main.py
0d44831 verified
raw
history blame
981 Bytes
# main.py
import logging
import uvicorn
from fastapi import FastAPI
import asyncio
from bot import start_bot
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
app = FastAPI(
title="Terabox Downloader Bot API",
version="1.0.0"
)
dp, bot = start_bot()
@app.on_event("startup")
async def startup_event():
logger.info("Starting bot polling in background...")
asyncio.create_task(dp.start_polling(bot))
@app.get("/", tags=["root"])
async def read_root():
return {
"message": "✅ Terabox Downloader Bot is running!",
"workers": "4", # You can even dynamically count your workers
"status": "OK"
}
@app.get("/health", tags=["health"])
async def health_check():
return {
"status": "ok",
"bot_username": (await bot.me()).username,
"forward_channel": f"{bot.id}",
"version": "1.0.0"
}
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=7860)