Skip to content

Instantly share code, notes, and snippets.

@mrichman
Created October 25, 2019 11:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichman/020ac039ace1c95cb6a409d7ce22e80f to your computer and use it in GitHub Desktop.
Save mrichman/020ac039ace1c95cb6a409d7ce22e80f to your computer and use it in GitHub Desktop.
Simple HTTPS Server in Python
#!/usr/bin/env python3
"""
generate server.pem:
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
"""
from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
httpd = HTTPServer(("localhost", 5000), 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