Forums

Using @app.route instead of @route with Bottle

I'm trying to build my first website using Bottle and I'm stuck on something that is probably really trivial and easy. I've got my app working fine so long as I use the default app. As in I stick with something like this:

from bottle import route
@route('/')
def serve_something():  ...

What I want to do is this:

from bottle import Bottle
app = Bottle()
@app.route('/')
def serve_something(): ...

I'm assuming I have to modify the line "application = default_app()" at the bottom of the app but I haven't been able to figure out how to make it work.

I think you may be able to use application = app.default_app()

That gives me the following error:

AttributeError: 'Bottle' object has no attribute 'default_app'

Nevermind, I figured it out. It was just setting it to

application = app

I tried that before but it didn't seem to work. I probably did something silly like forget to hit the "reload" button. Silly me.