Skip to content

Instantly share code, notes, and snippets.

@cablehead
Created April 3, 2015 21:27
Show Gist options
  • Save cablehead/43f9b583a25ad6d1f6c5 to your computer and use it in GitHub Desktop.
Save cablehead/43f9b583a25ad6d1f6c5 to your computer and use it in GitHub Desktop.
import vanilla
h = vanilla.Hub()
def handle_request(request):
print request
request.reply(vanilla.http.Status(200), {}, "Hello")
def handle_connection(conn):
for request in conn:
h.spawn(handle_request, request)
server = h.http.listen(8080)
@h.spawn
def _():
for conn in server:
h.spawn(handle_connection, conn)
print "serving..."
h.stop_on_term()
print "peace."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment