Last active
February 2, 2020 18:28
-
-
Save pichuang/33049eb546169e05a68d2bea8a8ef5ad to your computer and use it in GitHub Desktop.
Create Simple HTTPS Server using Python2 and 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
#!/bin/bash | |
firewall-cmd --list-all | |
firewall-cmd --zone=public --add-port=80/tcp --permanent | |
firewall-cmd --zone=public --add-port=443/tcp --permanent | |
firewall-cmd --reload | |
firewall-cmd --list-all |
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
import BaseHTTPServer, SimpleHTTPServer | |
import ssl | |
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), | |
SimpleHTTPServer.SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket (httpd.socket, | |
keyfile="path/tp/key.pem", | |
certfile='path/to/cert.pem', server_side=True) | |
httpd.serve_forever() |
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, BaseHTTPRequestHandler | |
import ssl | |
httpd = HTTPServer(('localhost', 4443), BaseHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket (httpd.socket, | |
keyfile="path/to/key.pem", | |
certfile='path/to/cert.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