How to retrieve GET vars in python bottle app

bottle, python, query-string

Solution

They are stored in the `request.query` object.

http://bottlepy.org/docs/dev/tutorial.html#query-variables

It looks like you can also access them by treating the `request.query` attribute like a dictionary:

request.query['city']

So `dict(request.query)` would create a dictionary of all the query parameters.

As @mklauber notes, this will not work for multi-byte characters. It looks like the best method is:

my_dict = request.query.decode()

or:

dict(request.query.decode())

to have a `dict` instead of a `<bottle.FormsDict object at 0x000000000391B...>` object.

Problem

I'm trying to make a simple REST api using the Python bottle app. I'm facing a problem in retrieving the GET variables from the request global object. Any suggestions how to retrieve this from the GET request?

Original source