I can access a value on request.form
if I pass a string in directly. However, if I assign the string to a variable and try to use that, it fails. Why doesn't the second print statement below work?
@app.route("/test", methods=['GET', 'POST'])
def test():
if request.method == 'POST':
# this works fine
print(request.form.get('lastname'))
# this doesn't -- why?
somevar = '\'lastname\''
print(request.form.get(somevar))
return "<p> check console </p>"
else:
return render_template('test.html')
<form method="post">
<input type="text" name="lastname">
<button type="submit" >Submit</button>
</form>