title: Python SSL server gives me "501 Unsupported method GET"
body: <p>I've followed <a href="https://anvileight.com/blog/2016/03/20/simple-http-server-with-python/" rel="noreferrer">this link</a> to build a simple file server with SSL.</p>
  
  <pre><code>from http.server import HTTPServer, BaseHTTPRequestHandler
  import ssl
  
  httpd = HTTPServer(('localhost', 4443), BaseHTTPRequestHandler)
  
  # openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
  httpd.socket = ssl.wrap_socket (httpd.socket, keyfile="key.pem", certfile='cert.pem', server_side=True)
  
  httpd.serve_forever()
  </code></pre>
  
  <p>I have created a certificate successfully, <code>key.pem</code> and <code>cert.pem</code> file paths are cool and I can start the server using <code>python server.py</code>. I am asked for a password, enter it, then it freezes for a bit and then it seems to run.</p>
  
  <p>However, when I enter some URL such as <code>https://localhost:4443/index.html</code> I get <strong>500 Unsupported method GET. Error code explanation: HTTPStatus.NOT_IMPLEMENTED - Server does not support this operation.</strong> Do I need to do something more to make my server serve the current directory? Until now I have just used <code>python -m http.server 8000</code> (<code>SimpleHTTPServer</code> when on Mac.) I am using Python 3.</p>
  
  <p>This is an will stay local so don't worry about the <code>PEM</code> files and the server script being exposed through it (if it worked!). I am also okay with the certificate being untrusted and instructed Chrome to visit the page anyway. I just need it to allow me to access camera without having to deploy my app somewhere with a legit cert.</p>