简体   繁体   中英

How do I actually use WSGI?

Suppose I have a function

def app2(environ, start_response)

If I know that a server implements WSGI, how can I tell the server to call app2 when it receives a HTTP request? app2 here is a function that takes a dictionary and returns a response (a WSGI application).

Depends on the server. The WSGI-Spec says nothing about that. But mod_wsgi for example expects to find the WSGI-Applications under the name application in the specified module, but you can configure that with the WSGICallableObject configuration directive.

If, as it sounds from your comment, your question is about Google App Engine, it provides a convenience function run_wsgi_app for running WSGI apps. So if your function is called app2 , you would run

def main():
   run_wsgi_app(app2)

For more, see http://code.google.com/appengine/docs/python/tools/webapp/utilmodule.html#run_wsgi_app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM