I run bottle as part of an environment and cannot understand how to pass variables to its routing functions. The following code runs fine:
import bottle
class WebServer():
message1 = 'hello message1'
def __init__(self):
self.message2 = 'hello message2'
bottle.run(host='localhost', port=8080)
@bottle.get('/hello')
def hello():
# here I would like to return message1 or message2
return 'unfortunately only a static message so far'
WebServer()
I would like to return message1
or message2
(two separate cases) when calling the /hello
URL. I do not know how to pass self
to hello()
, though. How should I do that?