mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix static handler 404 error
This commit is contained in:
parent
47305d74d9
commit
2e2d338c9d
15
app/classes/web/static_handler.py
Normal file
15
app/classes/web/static_handler.py
Normal file
@ -0,0 +1,15 @@
|
||||
import tornado.web
|
||||
from typing import (
|
||||
Optional
|
||||
)
|
||||
|
||||
from app.classes.shared.console import console
|
||||
|
||||
class CustomStaticHandler(tornado.web.StaticFileHandler):
|
||||
def validate_absolute_path(self, root: str, absolute_path: str) -> Optional[str]:
|
||||
try:
|
||||
return super().validate_absolute_path(root, absolute_path)
|
||||
except tornado.web.HTTPError as error:
|
||||
if 'HTTP 404: Not Found' in str(error):
|
||||
self.set_status(404)
|
||||
self.finish({'error':'NOT_FOUND', 'info':'The requested resource was not found on the server'})
|
@ -25,6 +25,7 @@ try:
|
||||
from app.classes.web.ajax_handler import AjaxHandler
|
||||
from app.classes.web.api_handler import ServersStats, NodeStats
|
||||
from app.classes.web.websocket_handler import SocketHandler
|
||||
from app.classes.web.static_handler import CustomStaticHandler
|
||||
from app.classes.shared.translation import translation
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
@ -143,7 +144,9 @@ class Webserver:
|
||||
autoreload=False,
|
||||
log_function=self.log_function,
|
||||
login_url="/login",
|
||||
default_handler_class=PublicHandler
|
||||
default_handler_class=PublicHandler,
|
||||
static_handler_class=CustomStaticHandler,
|
||||
serve_traceback=debug_errors,
|
||||
)
|
||||
|
||||
self.HTTP_Server = tornado.httpserver.HTTPServer(app)
|
||||
|
Loading…
Reference in New Issue
Block a user