import asyncio import os from fastapi import FastAPI from fastapi.responses import HTMLResponse from fastapi.staticfiles import StaticFiles app = FastAPI() # مسار بناء اللعبة باستخدام pygbag BUILD_PATH = "build/web" @app.on_event("startup") async def build_game(): # هي الخطوة بتحول كود game.py لملفات ويب وقت التشغيل print("Building game with pygbag...") os.system("python3 -m pygbag --build /code/game.py") @app.get("/", response_class=HTMLResponse) async def get_game(): index_path = os.path.join(BUILD_PATH, "index.html") if os.path.exists(index_path): with open(index_path, "r") as f: return f.read() return """

Building Orbit Wars... Please refresh in 10 seconds 🚀

""" # مشاركة الملفات الناتجة (JS/WASM) if os.path.exists(BUILD_PATH): app.mount("/", StaticFiles(directory=BUILD_PATH), name="static")