from gevent import monkey monkey patch_all import time from gevent ser

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from gevent import monkey
monkey.patch_all()
import time
from gevent.server import StreamServer
def req_handler(sock, addr):
fsock = sock.makefile(mode='rb')
while True:
line = fsock.readline()
time.sleep(666)
if not line.rstrip():
break
sock.sendall(b'HTTP 200 OK\r\n\r\n')
sock.close()
if __name__ == '__main__':
host = '127.0.0.1'
port = 8888
server = StreamServer((host, port), req_handler)
print('Listening on %s:%s' % (host, port))
server.serve_forever()