mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
fixed endless redirect issue on non-existant paths
This commit is contained in:
parent
de98e5727c
commit
81d5ff05e8
@ -27,7 +27,6 @@ class Controller:
|
||||
self.servers_list = []
|
||||
|
||||
servers = db_helper.get_all_defined_servers()
|
||||
print(servers)
|
||||
|
||||
for s in servers:
|
||||
settings_file = os.path.join(s['path'], 'server.properties')
|
||||
|
23
app/classes/web/default_handler.py
Normal file
23
app/classes/web/default_handler.py
Normal file
@ -0,0 +1,23 @@
|
||||
import logging
|
||||
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DefaultHandler(BaseHandler):
|
||||
|
||||
def get(self, page=None):
|
||||
|
||||
# sensible defaults
|
||||
template = "public/404.html"
|
||||
|
||||
self.render(template)
|
||||
|
||||
def post(self, page=None):
|
||||
|
||||
# sensible defaults
|
||||
template = "public/404.html"
|
||||
|
||||
self.render(template)
|
||||
|
@ -35,8 +35,12 @@ class PanelHandler(BaseHandler):
|
||||
'hosts_data': db_helper.get_latest_hosts_stats()
|
||||
|
||||
}
|
||||
print(page_data['hosts_data'])
|
||||
# print(page_data['hosts_data'])
|
||||
|
||||
# if no servers defined, let's go to the build server area
|
||||
if page_data['server_stats']['total'] == 0:
|
||||
self.redirect("server/step1")
|
||||
return False
|
||||
|
||||
if page == 'unauthorized':
|
||||
template = "panel/denied.html"
|
||||
|
@ -60,7 +60,7 @@ class PublicHandler(BaseHandler):
|
||||
|
||||
# if we have no page, let's go to login
|
||||
else:
|
||||
self.redirect("public/login")
|
||||
self.redirect("/public/login")
|
||||
|
||||
self.render(template, data=page_data)
|
||||
|
||||
|
@ -20,6 +20,7 @@ try:
|
||||
import tornado.httpserver
|
||||
from app.classes.web.public_handler import PublicHandler
|
||||
from app.classes.web.panel_handler import PanelHandler
|
||||
from app.classes.web.default_handler import DefaultHandler
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical("Import Error: Unable to load {} module".format(e, e.name))
|
||||
@ -117,7 +118,7 @@ class webserver:
|
||||
tornado.locale.set_default_locale(lang)
|
||||
|
||||
handlers = [
|
||||
(r'/', PublicHandler),
|
||||
(r'/', DefaultHandler),
|
||||
(r'/public/(.*)', PublicHandler),
|
||||
(r'/panel/(.*)', PanelHandler),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user