Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import socket
def serve():
listener = socket.socket()
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind(('', 8080))
while True:
s, addr = listener.accept()
request = s.recv(10000)
print 'request text:', request
method, rest = request.split(' ', 1)
path, rest = rest.split(None, 1)
print 'method:', method
print 'path:', path
s.send('you asked to '+method+' '+path)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment