mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Adding error 503 catcher
This commit is contained in:
parent
cdf75ced9a
commit
f6744d3e39
3 changed files with 16 additions and 2 deletions
|
@ -8,12 +8,12 @@ from starlette.middleware.sessions import SessionMiddleware
|
||||||
import aurweb.config
|
import aurweb.config
|
||||||
|
|
||||||
from aurweb.db import get_engine
|
from aurweb.db import get_engine
|
||||||
from aurweb.routers import html, sso
|
from aurweb.routers import html, sso, errors
|
||||||
|
|
||||||
routes = set()
|
routes = set()
|
||||||
|
|
||||||
# Setup the FastAPI app.
|
# Setup the FastAPI app.
|
||||||
app = FastAPI()
|
app = FastAPI(exception_handlers=errors.exceptions)
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
|
|
|
@ -8,7 +8,13 @@ async def not_found(request, exc):
|
||||||
return render_template("errors/404.html", context)
|
return render_template("errors/404.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
async def service_unavailable(request, exc):
|
||||||
|
_ = l10n.get_translator_for_request(request)
|
||||||
|
context = make_context(request, "503 - {_('Service Unavailable')}")
|
||||||
|
return render_template("errors/503.html", context)
|
||||||
|
|
||||||
# Maps HTTP errors to functions
|
# Maps HTTP errors to functions
|
||||||
exceptions = {
|
exceptions = {
|
||||||
404: not_found,
|
404: not_found,
|
||||||
|
503: service_unavailable
|
||||||
}
|
}
|
||||||
|
|
8
templates/errors/503.html
Normal file
8
templates/errors/503.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{% extends 'partials/layout.html' %}
|
||||||
|
|
||||||
|
{% block pageContent %}
|
||||||
|
<div class="box 404">
|
||||||
|
<h2>503 - {% trans %}Service Unavailable{% endtrans %}</h2>
|
||||||
|
<p>{% trans %}Don't panic! This site is down due to maintenance. We will be back soon.{% endtrans %}</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Add table
Reference in a new issue