First, let me just say that I have searched for information on this topic; there are a number of stackoverflow posts that all reference the same blog post from 2008:
http://boodebr.org/main/python/cherrypy-under-google-appserver#comment-51142
I understand that the new CherryPy version no longer requires the patch this blog post mentions. I have the cherrypy folder in the root of my GAE app - and I don't get an error when I import it in my program - but beyond the "import cherrypy" line, I can't get it to work. I'm not sure how to change the app.yaml file to properly reflect that I am using cherrypy, and not webbapp2 (or if that is important).
Is someone aware of an updated tutorial that could walk me through CherryPy/GAE? Or, could someone be so kind as to post the simple hello world program that will work using cherrypy in GAE?
Edit: If it helps, here's the code I have in main.py right now - it returns two 404 errors from cherrypy.
import cherrypy
import wsgiref.handlers
class Root:
def index(self):
return "Hello, CherryPy!"
app = cherrypy.tree.mount(Root(), "/")
wsgiref.handlers.CGIHandler().run(app)
I've a website running in GAE with cherrypy, it is very straight forward, you code is correct but you are not exposing the index
method that explain the 404
.
Anyway you should use the run_wsgi_app that GAE provides, so your code will look like this:
import cherrypy
from google.appengine.ext.webapp.util import run_wsgi_app
class Root(object):
@cherrypy.expose
def index(self):
return 'Hello CherryPy!'
app = cherrypy.tree.mount(Root(), '/')
run_wsgi_app(app)