We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a3cab7b commit 1378d89Copy full SHA for 1378d89
simpleServer/webserver01.py
@@ -0,0 +1,21 @@
1
+import socket
2
+
3
+HOST, PORT = '', 8888
4
5
+listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
6
+listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
7
+listen_socket.bind((HOST, PORT))
8
+listen_socket.listen(1)
9
+print 'Serving HTTP on port %s ...' % PORT
10
+while True:
11
+ client_connection, client_address = listen_socket.accept()
12
+ request = client_connection.recv(1024)
13
+ print request
14
15
+ http_response = """\
16
+HTTP/1.1 200 OK
17
18
+Hello, World!
19
+"""
20
+ client_connection.sendall(http_response)
21
+ client_connection.close()
0 commit comments