Skip to content Skip to sidebar Skip to footer

Problems Deploying Bottle Application With Google App Engine

newbie here--I've been trying to create a 'Hello World' in bottle using google app engine. I got the 'hello world' part to show up, but even on on index page, I get the following o

Solution 1:

Here's a good tutorial for bottle on GAE: http://blog.rutwick.com/use-bottle-python-framework-with-google-app-engine

DISCLAIMER: I did not run the tutorial, but it looks correct.

main.py:

from framework import bottle
from framework.bottle import route, template, request, error, debug
from google.appengine.ext.webapp.util import run_wsgi_app

@route('/')
def DisplayForm():
    message = 'Hello World'
    output = template('templates/home', data = message)
    return output

def main():
    debug(True)
    run_wsgi_app(bottle.default_app())

@error(403)
def Error403(code):
    return 'Get your codes right dude, you caused some error!'

@error(404)
def Error404(code):
    return 'Stop cowboy, what are you trying to find?'

if __name__=="__main__":
    main()

app.yaml:

application: my-bottle-app
version: 1
runtime: python
api_version: 1

handlers:
- url: /styles
  static_dir: styles

- url: /.*
  script: main.py

As you see there, are a number of differences from your sample code. The tutorial does a good job of explaining them, so I won't go into detail here.


Solution 2:

This might help:

app.yaml:

application: my-app
version: 1
runtime: python27
api_version: 1
threadsafe: yes

- url: .*
  script: main.app

main.py:

import bottle

@bottle.route('/')
def root():
    return 'hello!'

bottle.run(server='gae', debug=True)
app = bottle.app()

Here's the original answer from GitHub. https://github.com/defnull/bottle/issues/401


Solution 3:

When using WSGI like in the App Engine + Bottle started code, you can call bottle.debug() when your code is running on the dev server:

import bottle
import os

DEBUG = os.environ.get('SERVER_SOFTWARE','').startswith('Development')  
bottle.debug(DEBUG)
app = bottle.Bottle()

And in app.yaml:

handlers:
- url: .*
  script: main.app

Post a Comment for "Problems Deploying Bottle Application With Google App Engine"