add 404 with redirect countdown

This commit is contained in:
BennyThink
2021-03-22 00:06:37 +08:00
parent 2df1474fc4
commit 7986a59590
2 changed files with 15 additions and 3 deletions

11
web/404.html vendored
View File

@@ -1,5 +1,5 @@
<!doctype html>
<html>
<html lang="en">
<head>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Pacifico&display=swap" rel="stylesheet">
@@ -29,13 +29,20 @@
width: 75%;
}
</style>
<meta charset="utf-8">
<title>人人影视下载分享 404</title>
</head>
<body>
<div class="centered">
<h1>404 Not Found</h1>
<h2>Oh dang! We couldn't find that page.</h2>
<h2>你访问的页面不存在,将会在三秒钟内跳转回首页哦!</h2>
<img id="ferris" alt="a sad crab is unable to unable to lasso a paper airplane. 404 not found."
src="img/404-wrangler-ferris.gif">
</div>
</body>
<script>
setTimeout(function () {
window.location.href = '/';
}, 3000);
</script>
</html>

View File

@@ -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):