Commit 92f03301 authored by Denis Bilenko's avatar Denis Bilenko

add examples/httpserver.py

parent 7aa3ee0a
"""HTTP server listening on port 8800.
Uses libevent API directly and thus may be dangerous.
WSGI interface is probably a safer choice, see examples/wsgiserver.py.
"""
from gevent import http
def callback(r):
if r.uri == '/':
r.add_output_header('Content-Type', 'text/html')
r.send_reply(200, "OK", '<b>hello world</b>')
else:
r.add_output_header('Content-Type', 'text/html')
r.send_reply(404, "Not Found", "<h1>Not Found</h1>")
print __doc__
http.HTTPServer(callback).serve_forever(('0.0.0.0', 8800))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment