I want to get the "username" from the input field and put it in my url_for function to build a dynamic route for a user when he logs in. At the moment i am using url_for('function',username="username"). It always redirects me to a url with /username. I want the value passed in by the user to be shown instead. This is my code for forms:
`<form action="" method="post">
<input type="text" name="username" placeholder="Name" >
<input type="password" name="password" placeholder="password">
<button type="submit"> Submit </button>
</form>`
I want the value of 'name' field in the 'username' This is routing function:
@app.route("/<username>", methods=['post'])
def profile(username):
username = request.form.get("username")
password = request.form.get("password")
return render_template("layout.html",username=username,password=password)
Aucun commentaire:
Enregistrer un commentaire