Browse Source

Added HTTPS Redirect server

master
Macoy Madson 2 years ago
parent
commit
f3933651e1
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      RedirectToHttpsServer.py

+ 25
- 0
RedirectToHttpsServer.py View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
import os
import tornado.httpserver
import tornado.web
import tornado.ioloop
# From https://stackoverflow.com/questions/18353035/redirect-http-requests-to-https-in-tornado
class MainHandler(tornado.web.RequestHandler):
def prepare(self):
if self.request.protocol == 'http':
self.redirect('https://' + self.request.host, permanent=False)
def get(self):
self.write("Redirecting to HTTPS")
if __name__ == "__main__":
application = tornado.web.Application([
(r'/', MainHandler)
])
application.listen(80)
tornado.ioloop.IOLoop.current().start()

Loading…
Cancel
Save