2021-08-24 02:25:19 +00:00
|
|
|
import logging
|
2022-04-11 05:23:55 +00:00
|
|
|
import requests
|
2021-08-24 02:25:19 +00:00
|
|
|
|
|
|
|
from app.classes.web.base_handler import BaseHandler
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2022-03-23 02:50:12 +00:00
|
|
|
|
2021-08-24 02:25:19 +00:00
|
|
|
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] != "":
|
2022-03-23 02:50:12 +00:00
|
|
|
url = "https://" + url_list[0]
|
2021-08-24 02:25:19 +00:00
|
|
|
else:
|
2022-03-23 02:50:12 +00:00
|
|
|
url = "https://" + url
|
2022-04-11 05:23:55 +00:00
|
|
|
db_port = self.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-03-23 02:50:12 +00:00
|
|
|
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] != "":
|
2022-03-23 02:50:12 +00:00
|
|
|
url = "https://" + url_list[0]
|
2021-08-24 02:25:19 +00:00
|
|
|
else:
|
2022-03-23 02:50:12 +00:00
|
|
|
url = "https://" + url
|
2022-04-11 05:23:55 +00:00
|
|
|
db_port = self.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-03-23 02:50:12 +00:00
|
|
|
self.redirect(url + ":" + str(port))
|