title: HTTPS to HTTP using CherryPy
body: <p>Is it possible for CherryPy to redirect HTTP to HTTPS. Lets for example say the code below is <a href="http://example.com" rel="nofollow">http://example.com</a> if someone visits via <a href="https://example.com" rel="nofollow">https://example.com</a> I want them to be redirected to the plain HTTP URL (301 redirect maybe?) how do I accomplish this?</p>
  
  <pre><code>#!/usr/bin/env python
  
  from pprint import pformat
  from cherrypy import wsgiserver
  
  def app(environ, start_response):
      status = '200 OK'
      response_headers = [('Content-type', 'text/plain')]
      start_response(status, response_headers)
      return [pformat(environ)]
  
  server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 80), app)
  
  try:
      server.start()
  except KeyboardInterrupt:
      server.stop()
  </code></pre>