Can't navigate to "/ login" with jar?
When I type /login
in as url it is 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 turns 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
, everything will be fine. How does this happen?
source to share
Please read the quickstart checkbox Unique URLs / Redirect Behavior , URL canonicalization, and Tracking slash in URLs - which style is preferred?
source to share
EDIT
You can turn off strict url mode in route module to get the request/login/
Add the following code after app = Flask(__name__)
and before any routing definition.
app.url_map.strict_slashes = False
Original Answer
My chrome involves the request somehow. I open developer tools <F12>
and find that it automatically redirects my request /login
to /login/
.
General
Request URL:http://roxma.org:8000/hello
Request Method:GET
Status Code:301 MOVED PERMANENTLY (from disk cache)
Remote Address:127.0.0.1:1080
Request
Content-Length:263
Content-Type:text/html; charset=utf-8
Date:Wed, 28 Dec 2016 14:24:44 GMT
Location:http://roxma.org:8000/hello/
Server:Werkzeug/0.11.11 Python/3.5.1
It is not comfortable. I don't know how to fix this problem. I think the best solution is to use style /login/
.
source to share