Spaces:
Sleeping
Sleeping
# 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() | |
async def startup_event(): | |
logger.info("Starting bot polling in background...") | |
asyncio.create_task(dp.start_polling(bot_instance)) | |
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) | |
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) |