I'm working on a simple UI to start and stop games by ID. The basic HTML I have written is as follows (game_id
is populated by JS):
<div align="center" class="top">
<div align="left" class="game-id-input">
Game ID: <input type="text" name="game_id" id="game_id">
</div>
<div align="right" class="buttons">
<form action="{{ url_for('start_game', game_id=game_id) }}" method="get">
<input type="submit" name="start" value="Start game" class="btn btn-success"></input>
</form>
<form action="{{ url_for('end_game', game_id=game_id) }}" method="get">
<input type="submit" name="end" value="End game" class="btn btn-danger"></input>
</form>
</div>
</div>
which looks like
I also have Flask route functions defined for each of the forms:
@app.route("/start_game/<game_id>")
def start_game(game_id):
# ...
@app.route("/end_game/<game_id>")
def end_game(game_id):
# ...
In my forms, how can I make game_id
correspond to the game_id
from #game_id
?
Currently when I submit start and end games, I get a File Not Found error because it's just appending the literal <game_id>
to the route.
I'm new to web development. This should be trivial, but I don't know what to search for. Sorry in advance for such a simple question.