When I type /login
as url,it will go wrong
For example:
from flask import Flask ,url_for,render_template,request
app = Flask(__name__)
@app.route('/login')
def index():
return "index"
if __name__== "__main__":
app.run()
The error turn out to be like this:
Not Found.
The requested URL was not found on the server.
When I replace /login
with /login/
or any other words like /log
, it will be all right. How does that happen?
So let’s dive into the coding part. Flask-login uses Cookie-based Authentication. When the client logins via his credentials, Flask creates a session containing the user ID and then sends the session ID to the user via a cookie, using which he can log in and out as and when required.
You can use the Flask-Login module to do access control. It provides user session management for Flask: logging in, logging out, and remembering session. The module stores the user ID, restricts views to logged in users, protects cookies and has many other features. The Flask-login module we use is.
Flask-login uses Cookie-based Authentication. When the client logins via his credentials, Flask creates a session containing the user ID and then sends the session ID to the user via a cookie, using which he can log in and out as and when required. Now that it’s installed, let’s move into the coding part! 1. Coding the models.py file
Flask-login uses Cookie-based Authentication. When the client logins via his credentials, Flask creates a session containing the user ID and then sends the session ID to the user via a cookie, using which he can log in and out as and when required. First we need to install the Flask-Login
Please read the flask quickstart Unique URLs / Redirection Behavior, URL canonicalization and Trailing slash in URLs - which style is preferred?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With