Custom error pages

このコミットが含まれているのは:
n9k 2022-06-17 04:40:23 +00:00
コミット 35ce606d64
3個のファイルの変更36行の追加0行の削除

ファイルの表示

@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2022 n9k <https://git.076.ne.jp/ninya9k>
# SPDX-License-Identifier: AGPL-3.0-or-later
import anonstream.routes.errors
import anonstream.routes.core
import anonstream.routes.websocket
import anonstream.routes.nojs

8
anonstream/routes/errors.py ノーマルファイル
ファイルの表示

@ -0,0 +1,8 @@
from quart import current_app, render_template
from werkzeug.exceptions import default_exceptions
for error in default_exceptions:
async def handle(error):
return await render_template('error.html', error=error), error.code
current_app.register_error_handler(error, handle)

27
anonstream/templates/error.html ノーマルファイル
ファイルの表示

@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{ error.code }} {{ error.name }}</title>
<style>
body {
background-color: #18181a;
color: #ddd;
font-family: sans-serif;
font-size: 14pt;
margin: 24pt 16pt;
text-align: center;
text-shadow: 2px 0px 1px orangered;
}
h1 {
font-size: 32pt;
}
a {
color: #42a5d7;
}
</style>
</head>
<body>
<h1>{{ error.code }} {{ error.name }}</h1>
</body>
</html>