polished homepage, added game info table
This commit is contained in:
+13
-7
@@ -7,7 +7,7 @@ from flask_cors import CORS
|
||||
from flask_socketio import SocketIO
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app, origins=["http://localhost:3000", "10.*"])
|
||||
CORS(app, origins=["*", "0.0.0.0"])
|
||||
socketio = SocketIO(app, cors_allowed_origins="*")
|
||||
|
||||
|
||||
@@ -38,11 +38,10 @@ def add_player():
|
||||
|
||||
@app.route("/reset", methods=["GET"])
|
||||
def reset():
|
||||
game_state = {
|
||||
"gameActive": False,
|
||||
"players": [""],
|
||||
"playerTurn": 0
|
||||
}
|
||||
game_state["gameActive"] = False
|
||||
game_state["players"] = []
|
||||
game_state["playerTurn"] = 0
|
||||
socketio.emit("player_update", {"players": game_state["players"]})
|
||||
return jsonify(game_state)
|
||||
|
||||
|
||||
@@ -50,6 +49,13 @@ def reset():
|
||||
def status():
|
||||
return jsonify(game_state)
|
||||
|
||||
@app.route("/start", methods=["GET"])
|
||||
def start_game():
|
||||
game_state["gameActive"] = True
|
||||
socketio.emit("player_update", {"players": game_state["players"]})
|
||||
return jsonify(game_state)
|
||||
|
||||
|
||||
@app.route("/next", methods=["GET"])
|
||||
def next_player():
|
||||
players = game_state["players"]
|
||||
@@ -67,4 +73,4 @@ def next_player():
|
||||
})
|
||||
|
||||
if __name__ == "__main__":
|
||||
socketio.run(app, host="localhost", port=8080)
|
||||
socketio.run(app, host="0.0.0.0", port=8080)
|
||||
Reference in New Issue
Block a user