Remove http handler from codebase

This commit is contained in:
amcmanu3 2024-03-15 14:47:30 -04:00
parent 128be0a352
commit c9a46a1f9b
3 changed files with 0 additions and 102 deletions

View File

@ -1,42 +0,0 @@
import logging
import requests
from app.classes.web.base_handler import BaseHandler
logger = logging.getLogger(__name__)
class HTTPHandler(BaseHandler):
def get(self):
url = str(self.request.host)
port = 443
url_list = url.split(":")
if url_list[0] != "":
url = "https://" + url_list[0]
else:
url = "https://" + url
db_port = self.helper.get_setting("https_port")
try:
resp = requests.head(url + ":" + str(port), timeout=(0.5, 5))
resp.raise_for_status()
except Exception:
port = db_port
self.redirect(url + ":" + str(port))
class HTTPHandlerPage(BaseHandler):
def get(self):
url = str(self.request.host)
port = 443
url_list = url.split(":")
if url_list[0] != "":
url = "https://" + url_list[0]
else:
url = "https://" + url
db_port = self.helper.get_setting("https_port")
try:
resp = requests.head(url + ":" + str(port), timeout=(0.5, 5))
resp.raise_for_status()
except Exception:
port = db_port
self.redirect(url + ":" + str(port))

View File

@ -1,33 +0,0 @@
import logging
import requests
from app.classes.web.base_handler import BaseHandler
logger = logging.getLogger(__name__)
class HTTPHandlerPage(BaseHandler):
def get(self):
url = self.request.full_url
port = 443
if url[len(url) - 1] == "/":
url = url.strip(url[len(url) - 1])
url_list = url.split("/")
if url_list[0] != "":
primary_url = url_list[0] + ":" + str(port) + "/"
backup_url = (
url_list[0] + ":" + str(self.helper.get_setting("https_port")) + "/"
)
for i in range(len(url_list) - 1):
primary_url += url_list[i + 1]
backup_url += url_list[i + 1]
else:
primary_url = url + str(port)
backup_url = url + str(self.helper.get_setting("https_port"))
try:
resp = requests.head(primary_url, timeout=(0.5, 5))
resp.raise_for_status()
url = primary_url
except Exception:
url = backup_url
self.redirect("https://" + url + ":" + str(port))

View File

@ -25,7 +25,6 @@ from app.classes.web.server_handler import ServerHandler
from app.classes.web.websocket_handler import WebSocketHandler from app.classes.web.websocket_handler import WebSocketHandler
from app.classes.web.static_handler import CustomStaticHandler from app.classes.web.static_handler import CustomStaticHandler
from app.classes.web.upload_handler import UploadHandler from app.classes.web.upload_handler import UploadHandler
from app.classes.web.http_handler import HTTPHandler, HTTPHandlerPage
from app.classes.web.status_handler import StatusHandler from app.classes.web.status_handler import StatusHandler
@ -44,7 +43,6 @@ class Webserver:
file_helper: FileHelpers, file_helper: FileHelpers,
): ):
self.ioloop = None self.ioloop = None
self.http_server = None
self.https_server = None self.https_server = None
self.helper = helper self.helper = helper
self.controller = controller self.controller = controller
@ -173,30 +171,6 @@ class Webserver:
static_handler_class=CustomStaticHandler, static_handler_class=CustomStaticHandler,
serve_traceback=debug_errors, serve_traceback=debug_errors,
) )
http_handers = [
(r"/", HTTPHandler, handler_args),
(r"/(.+)", HTTPHandlerPage, handler_args),
]
http_app = tornado.web.Application(
http_handers,
template_path=os.path.join(self.helper.webroot, "templates"),
static_path=os.path.join(self.helper.webroot, "static"),
debug=debug_errors,
cookie_secret=cookie_secret,
xsrf_cookies=True,
autoreload=False,
log_function=self.log_function,
default_handler_class=HTTPHandler,
login_url="/login",
serve_traceback=debug_errors,
)
if http_port != 0:
self.http_server = tornado.httpserver.HTTPServer(http_app)
self.http_server.listen(http_port)
else:
logger.info("http port disabled by config")
self.https_server = tornado.httpserver.HTTPServer(app, ssl_options=cert_objects) self.https_server = tornado.httpserver.HTTPServer(app, ssl_options=cert_objects)
self.https_server.listen(https_port) self.https_server.listen(https_port)
@ -218,7 +192,6 @@ class Webserver:
logger.info("Shutting Down Web Server") logger.info("Shutting Down Web Server")
Console.info("Shutting Down Web Server") Console.info("Shutting Down Web Server")
self.ioloop.stop() self.ioloop.stop()
self.http_server.stop()
self.https_server.stop() self.https_server.stop()
logger.info("Web Server Stopped") logger.info("Web Server Stopped")
Console.info("Web Server Stopped") Console.info("Web Server Stopped")