3 ms·
test.py ======= import bottle @bottle.get('/') def index(): return 'INDEX' # a new wsgi app hello = bottle.Bottle()
by rambojazz 7y ago
test.py
=======
import bottle
@bottle.get('/')
def index():
return 'INDEX'
# a new wsgi app
hello = bottle.Bottle()
@hello.get('/<name>')
def greet(name):
return 'Hello, ' + name
bottle.app().mount('/hello', hello)
Test like this: python3 -m bottle --bind :8080 test
You should have 2 working routes, "/" and "/hello/<name>".
- e12e 7y agoThanks, that makes sense. But I'm still not clear on how I require "example.py" and mount it (ie how do I make an wsgi instance from a python file that is a bottle app)?