Skip to content

Instantly share code, notes, and snippets.

@techforum-repo
Created November 15, 2022 00:35
Show Gist options
  • Save techforum-repo/dc4d044f523d98588c416055c7cf28e2 to your computer and use it in GitHub Desktop.
Save techforum-repo/dc4d044f523d98588c416055c7cf28e2 to your computer and use it in GitHub Desktop.
import os
import sys
from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
PORT = 443
class HTTPRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
def server(port):
httpd = HTTPServer(('', port), HTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, keyfile="SSL/server.key", certfile='SSL/server.crt', server_side=True)
return httpd
if __name__ == "__main__":
port = PORT
httpd = server(port)
try:
os.chdir('data')
print("\nserving from data/ at localhost:" + str(port))
httpd.serve_forever()
except KeyboardInterrupt:
print("\n...shutting down http server")
httpd.shutdown()
sys.exit()
@techforum-repo
Copy link
Author

image

@techforum-repo
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment