Created
August 14, 2014 02:55
-
-
Save wendyjap/f59f1654fd5158291e93 to your computer and use it in GitHub Desktop.
Simple HTTPS server in python3
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
from http.server import HTTPServer,SimpleHTTPRequestHandler | |
from socketserver import BaseServer | |
import ssl | |
HOSTNAME = 'localhost' | |
HTTPS_PORT = 8443 | |
httpd = HTTPServer((HOSTNAME, HTTPS_PORT), SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, keyfile='server.key', certfile='server.crt', server_side=True) | |
print('Running https server on port {0}. Check it out with open https://{1}:{0}'.format(HTTPS_PORT, HOSTNAME)) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create the keyfile and certfile by running this command: