okoboko
okoboko

Reputation: 4502

Flask - Can't Read Value from URL (Querystring)

I have a view function defined like this:

@app.route('/blog', defaults={'page': 1})
@app.route('/blog?page=<int:page>')
def posts(page):
...

I goto this link:

http://example.com/blog?page=5

But, no matter what I try, the value of page is always 1.

What am I doing wrong? Using Flask 0.10.1.

Upvotes: 0

Views: 133

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600059

Routes don't work like that: they never match against querystring arguments. Just match on the path and get page from request.args.

Upvotes: 2

Related Questions