Skip to content

Commit

Permalink
Add code for Part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Spivak committed Mar 9, 2015
0 parents commit d482f01
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions part1/webserver1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import socket

HOST, PORT = '', 8888

listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listen_socket.bind((HOST, PORT))
listen_socket.listen(1)
print 'Serving HTTP on port %s ...' % PORT
while True:
client_connection, client_address = listen_socket.accept()
request = client_connection.recv(1024)
print request

http_response = """\
HTTP/1.1 200 OK
Hello, World!
"""
client_connection.sendall(http_response)
client_connection.close()

0 comments on commit d482f01

Please sign in to comment.