2022-03-23 02:50:12 +00:00
|
|
|
from typing import Optional
|
2022-03-08 04:40:44 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
import tornado.web
|
|
|
|
|
|
|
|
except ModuleNotFoundError as e:
|
|
|
|
from app.classes.shared.helpers import helper
|
2022-03-23 02:50:12 +00:00
|
|
|
|
2022-03-08 04:40:44 +00:00
|
|
|
helper.auto_installer_fix(e)
|
2021-04-17 15:12:23 +00:00
|
|
|
|
2022-03-23 02:50:12 +00:00
|
|
|
|
2021-04-17 15:12:23 +00:00
|
|
|
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:
|
2022-03-23 02:50:12 +00:00
|
|
|
if "HTTP 404: Not Found" in str(error):
|
2021-04-17 15:12:23 +00:00
|
|
|
self.set_status(404)
|
2022-03-23 02:50:12 +00:00
|
|
|
self.finish(
|
|
|
|
{
|
|
|
|
"error": "NOT_FOUND",
|
|
|
|
"info": "The requested resource was not found on the server",
|
|
|
|
}
|
|
|
|
)
|