Skip to content

Commit 1378d89

Browse files
committed
upload
1 parent a3cab7b commit 1378d89

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

simpleServer/webserver01.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)