Created
April 3, 2015 21:27
-
-
Save cablehead/43f9b583a25ad6d1f6c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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