[REST API] Query string vs Route parameter
Query string vs Route parameter
How did I encounter this?
While practicing on Flask, I saw the following cases:
@app.route('/login')
def login():
password = request.args.get('password')
email = request.args.get('email')
print(password, email)
values from the URL are retrieved using flask.request.args.get(<parameter_name>).
@app.route('/hello/<user>')
def hello_name(user):
return render_template('variable.html', name=user)
the value of the specified parameter is automatically retrieved and passed into the function
I got to wonder the difference between them.
Comments
Post a Comment