from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel import uvicorn from time import time app = FastAPI() main_req = "/apipanda/v2/game/755/tele2-panda-kombat/config" @app.get(main_req) async def root(): return { "canPlay": True, "serverTime": int(time()), "errorCode": 0, "errorMessage": None, "tryAvailable": 1, "nextFreeTryAt": int(time()) + 86400 } @app.options(main_req) async def opt(): return None @app.post("/apipanda/v2/game/755/tele2-panda-kombat/game/start") async def start(): return {"gameSessionId":"1234567890"} @app.options("/apipanda/v2/game/755/tele2-panda-kombat/game/start") async def start_opt(): return None class GameEnd(BaseModel): gameSessionId: str duration: int score: int @app.post("/apipanda/v2/game/755/tele2-panda-kombat/game/end") async def end(gameEnd: GameEnd): return {"win": 1} ## 0 если вебал @app.options("/apipanda/v2/game/755/tele2-panda-kombat/game/end") async def end_opt(): return None origins = [ "http://localhost:5500", "http://localhost:8000", "http://127.0.0.1:5500", "http://127.0.0.1:8000" ] app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8000)