2

How do I manage multiple apps in Bottle, served from the one run?

App 0

from bottle import Bottle

app0 = Bottle()

@app0.route('/app0/')
def app0_route():
    return {'`app0` says': 'Greetings!'}

App 1

from bottle import Bottle

app1 = Bottle()

@app1.route('/app1/')
def app1_route():
    return {'`app1` says': 'Greetings!'}

Main

if __name__ == '__main__':
    app0.run()    # How do I link `app1` here?
stackoverflowuser95
  • 1,992
  • 3
  • 20
  • 30

1 Answers1

4

You can merge all routes in app1 using Bottle.merge:

if __name__ == '__main__':
    app0.merge(app1)
    app0.run()

It does not change the original owner, see here.

iMom0
  • 12,493
  • 3
  • 49
  • 61