Skip to content

Instantly share code, notes, and snippets.

@Maddosaurus
Last active December 10, 2020 13:42
Show Gist options
  • Save Maddosaurus/ec4736680b273b73b811032d7c8b7a92 to your computer and use it in GitHub Desktop.
Save Maddosaurus/ec4736680b273b73b811032d7c8b7a92 to your computer and use it in GitHub Desktop.
Simple Python3 HTTPS server
# via https://stackoverflow.com/questions/22429648/ssl-in-python3-with-httpserver/22436756#22436756
# generate server.pem with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# This server serves the CWD as content
from http.server import HTTPServer,SimpleHTTPRequestHandler
from socketserver import BaseServer
import ssl
httpd = HTTPServer(('localhost', 443), SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='server.pem', server_side=True)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment