I am running an https server which serves the current directory using the following code.
#!/usr/bin/env python3
from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
httpd = HTTPServer(('hostname', 8443), SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket, keyfile="/Users/test/Desktop/key.pem", certfile="/Users/test/Desktop/cert.pem", server_side=True)
httpd.serve_forever()
I also wanted the server to be able to handle a POST request with some values. I want to log whatever is being sent as POST to a file. Previously I used cgi scripts for this purpose. I used to have a logger.py in ./cgi-bin and made the clients send POST request to http://hostname:8080/cgi-bin/logger.py. and invoked the server using python -m http.server --cgi 8080
However because of my new requirement to serve over https I am no longer invoking http.server from commandline and am using the above script. I have no idea POST requests can be handled without breaking the usual functionality of serving the contents inside the folder.