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 = []
|
self.servers_list = []
|
||||||
|
|
||||||
servers = db_helper.get_all_defined_servers()
|
servers = db_helper.get_all_defined_servers()
|
||||||
print(servers)
|
|
||||||
|
|
||||||
for s in servers:
|
for s in servers:
|
||||||
settings_file = os.path.join(s['path'], 'server.properties')
|
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()
|
'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':
|
if page == 'unauthorized':
|
||||||
template = "panel/denied.html"
|
template = "panel/denied.html"
|
||||||
|
@ -60,7 +60,7 @@ class PublicHandler(BaseHandler):
|
|||||||
|
|
||||||
# if we have no page, let's go to login
|
# if we have no page, let's go to login
|
||||||
else:
|
else:
|
||||||
self.redirect("public/login")
|
self.redirect("/public/login")
|
||||||
|
|
||||||
self.render(template, data=page_data)
|
self.render(template, data=page_data)
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ try:
|
|||||||
import tornado.httpserver
|
import tornado.httpserver
|
||||||
from app.classes.web.public_handler import PublicHandler
|
from app.classes.web.public_handler import PublicHandler
|
||||||
from app.classes.web.panel_handler import PanelHandler
|
from app.classes.web.panel_handler import PanelHandler
|
||||||
|
from app.classes.web.default_handler import DefaultHandler
|
||||||
|
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
logger.critical("Import Error: Unable to load {} module".format(e, e.name))
|
logger.critical("Import Error: Unable to load {} module".format(e, e.name))
|
||||||
@ -117,7 +118,7 @@ class webserver:
|
|||||||
tornado.locale.set_default_locale(lang)
|
tornado.locale.set_default_locale(lang)
|
||||||
|
|
||||||
handlers = [
|
handlers = [
|
||||||
(r'/', PublicHandler),
|
(r'/', DefaultHandler),
|
||||||
(r'/public/(.*)', PublicHandler),
|
(r'/public/(.*)', PublicHandler),
|
||||||
(r'/panel/(.*)', PanelHandler),
|
(r'/panel/(.*)', PanelHandler),
|
||||||
]
|
]
|
||||||
|
2
main.py
2
main.py
@ -97,8 +97,6 @@ if __name__ == '__main__':
|
|||||||
installer.create_tables()
|
installer.create_tables()
|
||||||
installer.default_settings()
|
installer.default_settings()
|
||||||
|
|
||||||
# installer.create_tables()
|
|
||||||
|
|
||||||
# init servers
|
# init servers
|
||||||
logger.info("Initializing all servers defined")
|
logger.info("Initializing all servers defined")
|
||||||
console.info("Initializing all servers defined")
|
console.info("Initializing all servers defined")
|
||||||
|
Loading…
Reference in New Issue
Block a user