The next step in my experiment is to get Restish working with Google App Engine. It turns out to be quite simple. The basic hello world app looks like the following:
#!/usr/bin/env python
import wsgiref.handlers
from restish import app, http, resource
class Root(resource.Resource):
@resource.GET()
def index(self, request):
return http.ok([], 'Hello World!')
def main():
application = app.RestishApp(Root())
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
You will also have to include the Restish source tree in your project (or use the zip importer to import it from a zip file). This example is about the simplest way possible to do it, and I bet it wouldn't be difficult to get a paste created project working on App Engine.
So far, so good. I'll report later if I run into any issues.
4 comments:
You're such a dork. ;)
Actually, it can be simpler - the Root resource can just be a function:
def root(request):
return http.ok([], 'Hello World!')
Yeah I know, a function is not terribly useful as a root resource but it comes in very handy for writing simple leaf resources so I thought it was worth mentioning ;-).
Also ... thanks for posting this example. It's great to see that restish runs just fine on GAE :).
Hey Matt, thanks for Restish! :)
I've only tested the very basics thus far, but hopefully I will be able to flex more of its muscles soon.
Post a Comment