Last active
December 10, 2020 13:42
-
-
Save Maddosaurus/ec4736680b273b73b811032d7c8b7a92 to your computer and use it in GitHub Desktop.
Simple Python3 HTTPS server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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