Skip to content

Instantly share code, notes, and snippets.

Created November 5, 2020 01:26
  • Star 27 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Python 3 Simple HTTPS server
#!/usr/bin/env python3
# python3 update of
# Create a basic certificate using openssl:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# Or to set CN, SAN and/or create a cert signed by your own root CA:
import http.server
import ssl
httpd = http.server.HTTPServer(('', 443), http.server.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True)
Copy link


If you want to expose it to the world, just change '' to ''

Copy link


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment