Scenario
- User requests the following URL:
curl -XGET http://127.0.0.1:5000/drinks?category=bubbletea
.
- How do I get the different parts of a request's url by using flask's request?
Snippet
request.method: GET
request.url_charset: utf-8
request.url_root: http://127.0.0.1:5000/
request.host_url: http://127.0.0.1:5000/
request.host: 127.0.0.1:5000
request.url: http://127.0.0.1:5000/drinks?category=bubbletea
request.base_url: http://127.0.0.1:5000/drinks
request.script_root: /drinks
str(request.url_rule): /drinks/category
request.path: /drinks/category
request.full_path: /drinks?category=bubbletea
request.args: ImmutableMultiDict([('category', 'bubbletea')])
request.args.get('category'): bubbletea
Reference
Flask Request Path