Last active
January 25, 2024 12:24
-
-
Save stephenlb/2e19d98039469b9d0134 to your computer and use it in GitHub Desktop.
HTTPS Server - All-in-One Secure 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/python | |
# server | |
# python https.py | |
# | |
# browser | |
# https://0.0.0.0:4443 | |
import BaseHTTPServer | |
import SimpleHTTPServer | |
import ssl | |
import os | |
os.system("openssl req -new -keyout server.pem -out server.pem -x509 -days 365 -nodes -subj '/CN=www.pubnub.com/O=PubNub/C=US'") | |
httpd = BaseHTTPServer.HTTPServer( ( '0.0.0.0', 4443 ), SimpleHTTPServer.SimpleHTTPRequestHandler ) | |
httpd.socket = ssl.wrap_socket( httpd.socket, certfile='./server.pem', server_side=True ) | |
os.system("rm server.pem") | |
os.system("open https://0.0.0.0:4443/") | |
try: httpd.serve_forever() | |
except KeyboardInterrupt: pass | |
print("Server was closed by user.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to run this in a Docker Container or a Unix system like Linux/MacOS.