bottle Python HTTP query parameters minimal example

In order to obtain the value of a query parameter named myparam in bottle, first import request:

from bottle import request

and then use


Full example:

#!/usr/bin/env python3
from bottle import route, run, request

def hello():
    query_param = request.params["myparam"]
    return f"myparam is {query_param}"

run(host='localhost', port=8080, debug=True)

Run this script and open http://localhost:8080/test?myparam=xyz in your browser - you will see

myparam is xyz