Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
3

[PYTHON] How do I change the replit database with an HTML button?

MrVoo
MrVoo

I'm making a flask thing and I'm trying to increase a value in the replit database by 1. Anyone know how to change the database by pressing a button on the page?

1 year ago
You are viewing a single comment. View All
1
CosmicBear
CosmicBear
<html> {{ test }} <a href="/add"><button>Add 1</button></a> </html>
@app.route('/add') def add(): db['num'] += 1 return redirect('/')

or,

<html> <form method="POST"> <button type="submit">Add 1</button> </form> </html>
@app.route('/') def index(): val = db["num"] if request.method == "POST": val += 1 return render_template("index.html", test = val)
1 year ago