Created
November 3, 2018 08:47
-
-
Save sunliwen/a14c47feb02d020962258455bd8c556a to your computer and use it in GitHub Desktop.
py https server
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" ([email protected]) | |
# | |
# 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 | |
port = 4443 | |
httpd = HTTPServer(("", port), SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, certfile="/home/dshwang/bin/https/server.pem", server_side=True) | |
print(separator) | |
print("Server running on https://localhost:" + str(port)) | |
print(separator) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment