import os import threading import sys from flask import Flask app = Flask(__name__) @app.route('/') def home(): return "Lichess Bot Wrapper is running!" def run_lichess_core(): # flush=True forces the log to print instantly on Hugging Face print("Launching Lichess Bot process...", flush=True) # The "-u" flag turns on unbuffered output for the main bot script os.system("python3 -u lichess-bot.py") if __name__ == "__main__": # Runs the actual bot logic in a background loop threading.Thread(target=run_lichess_core, daemon=True).start() # Keeps Hugging Face happy by listening on the mandatory port app.run(host="0.0.0.0", port=7860)