URL with slash and no slash in flask
When routing configuration via flask, there is a detail that is the same URL, with "/" and No "/" difference.
To illustrate:
For example, there is a URL named "/url"
First define both URLs, one with "/", One Without "/", the following code:
@app. Route ("/url")
def urlwithout ():
return "url with out/"
@app. Route ("/url/")
def Urlwith ():
return "url with/"
To access/url, the effect is as follows:
Access the/url/effect as follows:
And then/url this definition, and again visit/url, found to jump to/url/this address
If you comment out the definition of/url/, keep the definition of/url, visit/url/again, find the 404 error
Conclusion: When a URL with a slash and a slash is present, the two URLs are independent of each other to handle their own logic.
When a URL with a slash exists and the URL without a slash does not exist, the URL with the slash and the URL without the slash can be accessed at the same time, but the returned result is the same.
When the URL with the slash does not exist, the URL without the slash is present, the URL with the slash returns 404, and the URL without the slash is normally accessed.
Python Web development-flask URL with slash/And no slash/difference