Re:Why should bottlepy stick to a file?
by rambojazz on Sunday January 12, 2020 @03:29PM
(#22029071)
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 testYou should have 2 working routes, "/" and "/hello/<name>".
But looking at the quickstart, you typically don't subclass Bottle, you require it, and call run()? So your typical bottle app won't be a subclass of bottle? At which point you can't make an instance of it, to pass to mount()?
Looking at the documentation for mount() it looks like you should be able to mount the quick-start app - but it's not clear of you create an instance to pass to mount?
That is if I have example.py:
How do I write example_mount.py that mounts example.py under /hello1 and /hello2?