-
Notifications
You must be signed in to change notification settings - Fork 6
/
https.py
31 lines (24 loc) · 894 Bytes
/
https.py
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
28
29
30
31
import BaseHTTPServer, SimpleHTTPServer
import ssl
import logging
import cgi
import os
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
logging.error(self.headers)
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
def do_POST(self):
logging.error(self.headers)
form = cgi.FieldStorage(
fp=self.rfile,
headers=self.headers,
environ={'REQUEST_METHOD':'POST',
'CONTENT_TYPE':self.headers['Content-Type'],
})
for item in form.list:
logging.error(item)
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
Handler = ServerHandler
httpd = BaseHTTPServer.HTTPServer(('192.168.1.101', 443), Handler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='client.pem', server_side=True)
httpd.serve_forever()