404 error #560

Closed
sbitpdc opened this Issue Jul 21, 2012 · 2 comments

Comments

4 participants
@sbitpdc

sbitpdc commented Jul 21, 2012

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

This comment has been minimized.

Show comment Hide comment
@kylerob

kylerob Jul 22, 2012

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.

kylerob commented Jul 22, 2012

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

This comment has been minimized.

Show comment Hide comment
@untitaker

untitaker Aug 31, 2012

Owner

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

Owner

untitaker commented Aug 31, 2012

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

@mitsuhiko mitsuhiko closed this Oct 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment