Spaces:
Running
Running
Download main.py from BlueMoonBot/BubbleBot: direct link, hf CLI and curl.
- Browser
- Download file 888 Bytes
-
https://huggingface.co/spaces/BlueMoonBot/BubbleBot/resolve/main/main.py
- Command line
-
hf download hf://spaces/BlueMoonBot/BubbleBot/main.py
-
curl -L -o main.py https://huggingface.co/spaces/BlueMoonBot/BubbleBot/resolve/main/main.py
888 Bytes
| import subprocess | |
| import threading | |
| import uvicorn | |
| from fastapi import FastAPI | |
| app = FastAPI() | |
| def home(): | |
| # Hugging Face health checker hits this path. | |
| # Returning "OK" tells HF the Space is successfully "Running"! | |
| return {"status": "Bot is alive"} | |
| def run_lichess_bot(): | |
| print("Launching Lichess Bot process...") | |
| # This fires off your actual lichess-bot script in the background | |
| subprocess.run(["python", "lichess-bot-master/lichess-bot.py"]) | |
| if __name__ == "__main__": | |
| # 1. Start the lichess bot inside a background thread so it doesn't block the website | |
| bot_thread = threading.Thread(target=run_lichess_bot, daemon=True) | |
| bot_thread.start() | |
| # 2. Start the dummy web server on port 7860 that Hugging Face wants to see | |
| print("Starting health-check web server on port 7860...") | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |