2021-08-24 02:25:19 +00:00
|
|
|
import logging
|
|
|
|
import requests
|
|
|
|
|
|
|
|
from app.classes.shared.helpers import helper
|
|
|
|
from app.classes.web.base_handler import BaseHandler
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
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()
|
2022-01-26 01:45:30 +00:00
|
|
|
except Exception:
|
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):
|
2022-01-26 01:45:30 +00:00
|
|
|
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()
|
2022-01-26 01:45:30 +00:00
|
|
|
except Exception:
|
2021-08-24 02:54:52 +00:00
|
|
|
port = db_port
|
2022-01-26 01:45:30 +00:00
|
|
|
self.redirect(url+":"+str(port))
|