-
-
Save ikszero/be8abaf3d64ff5a9558b3c76613ec028 to your computer and use it in GitHub Desktop.
Simple HTTPS Server in Python 3
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| # Ported to Python 3 by Telmo "Trooper" (telmo.trooper@gmail.com) | |
| # | |
| # Original code from: | |
| # http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
| # https://gist.github.com/dergachev/7028596 | |
| # | |
| # To generate a certificate use: | |
| # openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes | |
| from http.server import HTTPServer, SimpleHTTPRequestHandler | |
| import ssl | |
| separator = "-" * 80 | |
| httpd = HTTPServer(("localhost", 4443), SimpleHTTPRequestHandler) | |
| httpd.socket = ssl.wrap_socket(httpd.socket, certfile="./server.pem", server_side=True) | |
| print(separator) | |
| print("Server running on https://localhost:4443") | |
| print(separator) | |
| httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment