Skip to content

Instantly share code, notes, and snippets.

@PotHix
Last active July 18, 2017 21:06
Show Gist options
  • Save PotHix/da2c0b4ab894f96077c8f20458ed06a6 to your computer and use it in GitHub Desktop.
Save PotHix/da2c0b4ab894f96077c8f20458ed06a6 to your computer and use it in GitHub Desktop.
#!/bin/sh
printf "\n\n\n\n\n\n\n" | openssl req -new -x509 -keyout /tmp/pemfile.pem -out /tmp/pemfile.pem -days 365 -nodes 2>/dev/null
cat <<EOF > /tmp/python-https-server.py
import ssl
import BaseHTTPServer, SimpleHTTPServer
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
request_path = self.path
print("\n----- Request Start ----->\n")
print(request_path)
print(self.headers)
print("<----- Request End -----\n")
self.send_response(200)
port = 4443
print('Listening on https://localhost:%s' % port)
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), RequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, server_side=True,
certfile='/tmp/pemfile.pem')
httpd.serve_forever()
EOF
chmod +x /tmp/python-https-server.py
# please use Python 2.7 for now
python /tmp/python-https-server.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment