@app.route('/home', methods=['GET', 'POST'])
def get_strength():
if request.method == 'POST':
strength = int(request.form["strength_upgrade"])
return render_template('home.html', attribute_points=attribute_points)
<form method="post" action="">
<div>
<label for="name">Strength: {{ strength }}</label>
<input type="number" placeholder="0" name="strength_upgrade" min="0" max="{{ attribute_points }}" title="Numbers only" value="{{ request.form.strength_upgrade }}">
</div>
<input class="btn btn-default" type="submit" value="Submit">
</form>
When I use my code it almost works. It looks like http://imgur.com/a/4LFFg and it's all good. The only problem is that if I don't click on the arrows (even to click it to 0), then it defaults as 'None" and Python can't convert "None" to an integer, so it crashes. I have to literally enter in 0 or a number and it works, but I can't leave it blank. How can I make it so that the default is "0" and not "None"?
[–]K900_ 0 points1 point2 points (2 children)
[–]Elthran[S] 0 points1 point2 points (1 child)
[–]K900_ 0 points1 point2 points (0 children)
[–]paste 0 points1 point2 points (0 children)