python - Does gevent has a basic http handler? -


i trying build basic web server using gevent.server, , curious know there basehttphandlers, can use.

yes, gevent comes 2 http server implementations can use:

  • gevent.wsgi - fast, libevent-based implementation, providing limited features.

  • gevent.pywsgi - slower, pure gevent implementation, providing more features (streaming, pipelining, ssl).

here simple example (extracted gevent documentation):

#!/usr/bin/python """wsgi server example""" __future__ import print_function gevent.pywsgi import wsgiserver  def application(env, start_response):     if env['path_info'] == '/':         start_response('200 ok', [('content-type', 'text/html')])         return [b"<b>hello world</b>"]     else:         start_response('404 not found', [('content-type', 'text/html')])         return [b'<h1>not found</h1>']  if __name__ == '__main__':     print('serving on 8088...')     wsgiserver(('', 8088), application).serve_forever() 

for more information, see http://www.gevent.org/servers.html

see http://blog.pythonisito.com/2012/08/building-web-applications-with-gevents.html


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -