Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask,jsonify,request,url_for,redirect
- app = Flask(__name__)
- @app.route('/home',methods=["POST","GET"])
- def home(name,lastname):
- if request.method == "GET":
- return '''
- <form method="POST" action="/home">
- <input type="text" name=name">
- <input type="text" lastname=lastname">
- <button type="submit"></button>
- '''
- else:
- return redirect(url_for('accept_data'))
- @app.route('/accept_data')
- def accept_data():
- name = request.args.get("name")
- lastname = request.args.get("lastname")
- if name and lastname:
- return "<h1>Your first name is {} and lastname is {}</h1>".format(name,lastname)
- else:
- return "<h1>You dont have a first and lastname </h1>"
- if __name__ == "__main__":
- app.run(debug=True)
Add Comment
Please, Sign In to add comment