web.py on Google App Engine

2019-03-15 21:42发布

I'm trying to get a web.py application running on GAE. I hoped that sth like the following might work

import web
from google.appengine.ext.webapp.util import run_wsgi_app

[...]

def main():
    app = web.application(urls, globals())
    run_wsgi_app(app)

But obviously the app object doesn't conform with the run_wsgi_app function's expectations. The error msg says sth like app has no __call__ function, so I tried passing app.run instead, but that didn't work either.

How can I make the call to run_wsgi_app work?

2条回答
来,给爷笑一个
2楼-- · 2019-03-15 22:04

Here is a snippet of StackPrinter, a webpy application that runs on top of Google App Engine.

from google.appengine.ext.webapp.util import run_wsgi_app
import web
...
app = web.application(urls, globals())

def main():

    application = app.wsgifunc()
    run_wsgi_app(application)

if __name__ == '__main__':
    main()
查看更多
别忘想泡老子
3楼-- · 2019-03-15 22:23

You don't need to import or use run_wsgi_app, web.py has a runcgi method that works perfectly!

if __name__  == '__main__':
    app.cgirun()
查看更多
登录 后发表回答