- Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathHTTP_Server.py
More file actions
Latest commit
27 lines (21 loc) · 688 Bytes
/
Copy pathHTTP_Server.py
File metadata and controls
27 lines (21 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
importSimpleHTTPServer
importSocketServer
importcgi
importsys
importsocket
PORT=int(sys.argv[1])
defstaticHttpServer(req):
print(req.headers)
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(req)
classServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
defdo_GET(self):
staticHttpServer(self)
defdo_POST(self):
body=self.rfile.read(int(self.headers['Content-Length']))
print(body)
staticHttpServer(self)
Handler=ServerHandler
httpd=SocketServer.TCPServer(("", PORT), Handler)
ip="127.0.0.1"
print"Serving at: http://%(interface)s:%(port)s"%dict(interface=ipor"localhost", port=PORT)
httpd.serve_forever()