Python Flask Sequence Of Gets And Post
Hi im working with python and flask im trying to make a page that server takes you to page 1 then you send information to the server then takes you to page 2. then you send infor
Solution 1:
This sort of logic should be handled within the template itself, or should be split among multiple pages.
Multiple page example:
@app.route('/1',methods=['GET', 'POST'])
def one():
if request.method == 'GET':
return render_template('SelectOption.html');
elif request.method == 'POST':
option = request.form['option'];
@app.route('/2',methods=['GET', 'POST'])
def two():
if request.method == 'POST':
return render_template('charts.html');
return render_template('Option1.html', option = option)
@app.route('/3',methods=['GET', 'POST'])
def three():
if request.method == 'POST':
return render_template('charts.html');
return render_template("Charts.html")
Split template example:
@app.route('/', methods=['GET', 'POST']
def root():
if request.method == 'POST':
return render_template('post.html');
return render_template('get.html');
post.html:
<html>
<head><title>Post</title></head>
<body>
<h1>Hello {{ request.form['username'] }}</h1>
</body>
get.html:
<html>
<head><title>Post</title></head>
<body>
<form action="/">
Name:<br> <input type="text" name="username"><br>
<input type="submit" value="Submit">
</form>
</body>
Post a Comment for "Python Flask Sequence Of Gets And Post"