Spaces:
Paused
Paused
Download app.py from saske560/Compresas-2: direct link, hf CLI and curl.
- Browser
- Download file 511 Bytes
-
https://huggingface.co/spaces/saske560/Compresas-2/resolve/main/app.py
- Command line
-
hf download hf://spaces/saske560/Compresas-2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/saske560/Compresas-2/resolve/main/app.py
511 Bytes
| from fastapi import FastAPI | |
| from contextlib import asynccontextmanager | |
| import threading | |
| import os | |
| def run_bot(): | |
| print('Bot lanzado desde FastAPI') | |
| os.system('python main.py') | |
| async def lifespan(app: FastAPI): | |
| bot_thread = threading.Thread(target=run_bot) | |
| bot_thread.start() | |
| yield # Aquí FastAPI inicia | |
| # Aquí podrías hacer limpieza al apagar si quisieras | |
| app = FastAPI(lifespan=lifespan) | |
| def read_root(): | |
| return {"message": "Bot online"} | |