From 7986a595903b5f5610f91963667b4c5714d69c79 Mon Sep 17 00:00:00 2001 From: BennyThink Date: Mon, 22 Mar 2021 00:06:37 +0800 Subject: [PATCH] add 404 with redirect countdown --- web/404.html | 11 +++++++++-- web/server.py | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web/404.html b/web/404.html index bd0da49..0658a03 100644 --- a/web/404.html +++ b/web/404.html @@ -1,5 +1,5 @@ - + @@ -29,13 +29,20 @@ width: 75%; } + + 人人影视下载分享 404

404 Not Found

-

Oh dang! We couldn't find that page.

+

你访问的页面不存在,将会在三秒钟内跳转回首页哦!

a sad crab is unable to unable to lasso a paper airplane. 404 not found.
+ diff --git a/web/server.py b/web/server.py index a265661..e0ab243 100644 --- a/web/server.py +++ b/web/server.py @@ -386,6 +386,11 @@ class BlacklistHandler(BaseHandler): self.write(resp) +class NotFoundHandler(BaseHandler): + def prepare(self): # for all methods + self.render("404.html") + + class RunServer: root_path = os.path.dirname(__file__) static_path = os.path.join(root_path, '') @@ -403,7 +408,7 @@ class RunServer: {'path': static_path}), ] - application = web.Application(handlers, xheaders=True) + application = web.Application(handlers, xheaders=True, default_handler_class=NotFoundHandler) @staticmethod def run_server(port, host, **kwargs):