How do I make bottle work with google app engine?

This is the code,

import webapp2
from framework import bottle
from framework.bottle import route, template, request, error, debug

@route('/')
def root():
         return 'hello world'
class MainHandler(webapp2.RequestHandler):
   def get(self):
        root()


app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)

All the dependencies are there (framework, bottle, etc), however, when I deploy it using GAE, I just get an empty page!

Also I tried these and none of them worked, perhaps GAE changed its settings:

  • http://blog.rutwick.com/use-bottle-python-framework-with-google-app-engine
  • problems deploying bottle application with google app engine

You have not followed the advice in those links. Most obviously, you are simply calling root without actually returning its result back as the response. In Python, you need to explicitly use return to send a value back from a function, which you don't do in get.

You are also hopelessly confused with setting up the handlers. If you're using bottle, use it: there's no need to have webapp in the mix as well. Webapp is an alternative to bottle, not something that is baked into GAE. Your links show exactly how to do this.


Another solution that worked perfectly for me: https://github.com/GoogleCloudPlatform/appengine-bottle-skeleton


Be aware to use:

app.run(server='gae')

Otherwise bottle will try to access your system and GAE will fail