Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
from fastapi import FastAPI
|
| 3 |
+
import uvicorn
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
@app.get("/")
|
| 8 |
+
def home():
|
| 9 |
+
return {"status": "Lichess bot is running!"}
|
| 10 |
+
|
| 11 |
+
async def run_lichess_bot():
|
| 12 |
+
print("Starting Lichess bot...")
|
| 13 |
+
# --- YOUR COURSERA / LICHESS BOT CODE GOES HERE ---
|
| 14 |
+
# Example:
|
| 15 |
+
# while True:
|
| 16 |
+
# await check_lichess_games()
|
| 17 |
+
# await asyncio.sleep(1)
|
| 18 |
+
pass
|
| 19 |
+
|
| 20 |
+
@app.on_event("startup")
|
| 21 |
+
async def startup_event():
|
| 22 |
+
# This fires off your chess bot in the background
|
| 23 |
+
# so it doesn't block the web server from starting
|
| 24 |
+
asyncio.create_task(run_lichess_bot())
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
# Hugging Face strictly requires port 7860
|
| 28 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|