tebrox / main.py
understanding's picture
Update main.py
41fd54e verified
raw
history blame
1.15 kB
# main.py
import logging
import asyncio
import uvicorn
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from bot import start_bot
# --- Setup ---
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
)
logger = logging.getLogger("main")
app = FastAPI()
# Start bot
dp, bot_instance = start_bot()
@app.on_event("startup")
async def startup_event():
logger.info("Starting bot polling in background...")
asyncio.create_task(dp.start_polling(bot_instance))
@app.get("/", response_class=HTMLResponse)
async def root():
html_content = """
<html>
<head><title>Terabox Bot Status</title></head>
<body style="font-family:sans-serif;">
<h1>✅ Terabox Bot is Running</h1>
<p>You can check /health endpoint too.</p>
</body>
</html>
"""
return HTMLResponse(content=html_content)
@app.get("/health")
async def health():
return {"status": "ok", "bot": "running"}
if __name__ == "__main__":
logger.info("===== Application Startup =====")
uvicorn.run("main:app", host="0.0.0.0", port=7860)