2021-08-24 02:25:19 +00:00
|
|
|
import sys
|
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
import tornado.web
|
|
|
|
import tornado.escape
|
|
|
|
import requests
|
|
|
|
|
|
|
|
from app.classes.shared.helpers import helper
|
|
|
|
from app.classes.web.base_handler import BaseHandler
|
|
|
|
from app.classes.shared.console import console
|
2021-09-08 22:01:10 +00:00
|
|
|
from app.classes.shared.main_models import Users, fn
|
2021-08-24 02:25:19 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
try:
|
|
|
|
import bleach
|
|
|
|
|
|
|
|
except ModuleNotFoundError as e:
|
|
|
|
logger.critical("Import Error: Unable to load {} module".format(e.name), exc_info=True)
|
|
|
|
console.critical("Import Error: Unable to load {} module".format(e.name))
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
class HTTPHandler(BaseHandler):
|
|
|
|
def get(self):
|
2021-08-24 02:54:52 +00:00
|
|
|
url = str(self.request.host)
|
2021-08-24 02:25:19 +00:00
|
|
|
port = 443
|
2021-08-24 02:54:52 +00:00
|
|
|
url_list = url.split(":")
|
2021-08-24 02:25:19 +00:00
|
|
|
if url_list[0] != "":
|
2021-08-24 02:54:52 +00:00
|
|
|
url = 'https://' + url_list[0]
|
2021-08-24 02:25:19 +00:00
|
|
|
else:
|
2021-08-24 02:54:52 +00:00
|
|
|
url = 'https://' + url
|
|
|
|
db_port = helper.get_setting('https_port')
|
2021-08-24 02:25:19 +00:00
|
|
|
try:
|
2021-08-24 02:54:52 +00:00
|
|
|
resp = requests.get(url + ":" + str(port))
|
2021-08-24 02:25:19 +00:00
|
|
|
resp.raise_for_status()
|
|
|
|
except Exception as err:
|
2021-08-24 02:54:52 +00:00
|
|
|
port = db_port
|
|
|
|
self.redirect(url+":"+str(port))
|
2021-08-24 02:25:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HTTPHandlerPage(BaseHandler):
|
|
|
|
def get(self, page):
|
2021-08-24 02:54:52 +00:00
|
|
|
url = str(self.request.host)
|
2021-08-24 02:25:19 +00:00
|
|
|
port = 443
|
2021-08-24 02:54:52 +00:00
|
|
|
url_list = url.split(":")
|
2021-08-24 02:25:19 +00:00
|
|
|
if url_list[0] != "":
|
2021-08-24 02:54:52 +00:00
|
|
|
url = 'https://' + url_list[0]
|
2021-08-24 02:25:19 +00:00
|
|
|
else:
|
2021-08-24 02:54:52 +00:00
|
|
|
url = 'https://' + url
|
|
|
|
db_port = helper.get_setting('https_port')
|
2021-08-24 02:25:19 +00:00
|
|
|
try:
|
2021-08-24 02:54:52 +00:00
|
|
|
resp = requests.get(url + ":" + str(port))
|
2021-08-24 02:25:19 +00:00
|
|
|
resp.raise_for_status()
|
|
|
|
except Exception as err:
|
2021-08-24 02:54:52 +00:00
|
|
|
port = db_port
|
|
|
|
self.redirect(url+":"+str(port))
|