How to get parameters from a URL with Flask?

  • Get parameters from a URL with Flask :

Let’s assume that you are having the following URL:

http://127.0.0.1/mypage?name=john&surname=smith

Here is a code for your view/controller:

@app.route('/mypage', methods=['GET', 'POST'])
def login():
    name = request.form['name']
    password = request.form['surname']

N.B.! You might want to check the validity of provided data to avoid vulnerabilities! Such validaton it depends on your application implementation.

  • Minimum Requirements and How-to:

Python3, Pip3, VirtualEnv, Flask

  • DONE!

Leave a Reply