diff --git a/app.py b/app.py index d17957a..628a7b5 100644 --- a/app.py +++ b/app.py @@ -189,17 +189,17 @@ class Room: rooms: dict[str, Room] = {} -API_ROOT = "http://127.0.0.1:8080" +API_ROOT = "http://127.0.0.1:8989" @app.GET("/") async def home(request): - return render("index.html", {"API_ROOT": API_ROOT}) + return render(request, "index.html", {"API_ROOT": API_ROOT}) @app.GET("/") async def home_with_id(request, id): - return render("index.html", {"API_ROOT": API_ROOT}) + return render(request, "index.html", {"API_ROOT": API_ROOT}) @app.POST("/join/") @@ -210,6 +210,7 @@ async def join(request, room_id): player = room.add_player() if player: return JSONResponse( + request, { "code": "JOIN", "id": player[0], @@ -217,11 +218,12 @@ async def join(request, room_id): "turn": room.turn.value, "board": room.board.serialize(), "ready": len(room.players) == 2, - } + }, ) else: return JSONResponse( - {"code": "FULL", "error": "Room Full", "board": room.board.serialize()} + request, + {"code": "FULL", "error": "Room Full", "board": room.board.serialize()}, ) @@ -509,11 +511,11 @@ async def static(request, fn): try: path = sanitize_filename(fn, Path("static/").resolve()) return ( - HTTPResponse("", content_type="application/octet-stream") + HTTPResponse(request, "", content_type="application/octet-stream") + path.read_bytes() ) except Exception: - return HTTPResponse("404 File Not Found", status=404) + return HTTPResponse(request, "404 File Not Found", status=404) if __name__ == "__main__": diff --git a/libs b/libs index 9947e2b..014cdd8 160000 --- a/libs +++ b/libs @@ -1 +1 @@ -Subproject commit 9947e2b429544e0145eec69f1a7601277ca60780 +Subproject commit 014cdd80e221918db3f2d25c66f9e75592f9074e