Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

404 error #560

Closed
sbitpdc opened this Issue · 2 comments

4 participants

@sbitpdc

I have a route:
@app.route("/links/", methods = ("GET", "POST"))
@app.route("/links/string:url/", methods = ("GET", "POST"))
def links(url = ""):
dosomething()

When I get 127.0.0.1:5000/links/www.4399.com/special/26.htm,it return 404 bad.
Why?

@kylerob

I think you need string:url in brackets in order to capture it:

@app.route("/links/<string:url>", methods = ("GET", "POST")).

Also, given that the example string has slashes in it, I think you want to use path instead of string:

<path:url>

According to the documentation, path should be used for strings that contain slashes in them. Check out http://flask.pocoo.org/docs/api/#url-route-registrations for more info.

@untitaker
Collaborator

@sbitpdc Use four spaces as intendation to make the code appear as such.

@mitsuhiko mitsuhiko closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.