Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -1,17 +1,14 @@
|
|
1 |
-
import threading
|
2 |
from fastapi import FastAPI
|
3 |
from core.integrations.telegram_bot import start_bot
|
|
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
bot_thread = threading.Thread(target=run_telegram_bot, daemon=True)
|
12 |
-
bot_thread.start()
|
13 |
|
14 |
@app.get("/")
|
15 |
async def root():
|
16 |
return {"status": "Bot de Telegram activo"}
|
17 |
-
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from core.integrations.telegram_bot import start_bot
|
3 |
+
import asyncio
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
+
@app.on_event("startup")
|
8 |
+
async def on_startup():
|
9 |
+
# Ejecuta el bot como una tarea asincrónica en el mismo event loop
|
10 |
+
asyncio.create_task(start_bot())
|
|
|
|
|
11 |
|
12 |
@app.get("/")
|
13 |
async def root():
|
14 |
return {"status": "Bot de Telegram activo"}
|
|