Return custom 404 page from spotter-manager, related to #269

This commit is contained in:
Disassembler 2018-08-14 15:10:32 +02:00
parent 3f8aee2d84
commit 86e411df12
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
4 changed files with 28 additions and 9 deletions

View File

@ -29,9 +29,9 @@ NGINX_TEMPLATE = '''server {{
proxy_pass http://{ip}:8080;
}}
error_page 502 /error.html;
location = /error.html {{
root /srv/spotter;
error_page 502 /502.html;
location = /502.html {{
root /srv/spotter/appmgr/templates;
}}
location = /spotter-ping {{
@ -69,9 +69,9 @@ server {{
root /srv/spotter;
}}
error_page 502 /error.html;
location = /error.html {{
root /srv/spotter;
error_page 502 /502.html;
location = /502.html {{
root /srv/spotter/appmgr/templates;
}}
location = /spotter-ping {{

View File

@ -3,7 +3,7 @@
import json
import os
from werkzeug.exceptions import BadRequest, HTTPException
from werkzeug.exceptions import BadRequest, HTTPException, NotFound
from werkzeug.routing import Map, Rule
from werkzeug.utils import redirect
from werkzeug.wrappers import Request, Response
@ -81,6 +81,10 @@ class WSGIApp(object):
try:
endpoint, values = adapter.match()
return getattr(self, endpoint)(request, **values)
except NotFound as e:
response = self.render_template('404.html')
response.status_code = 404
return response
except HTTPException as e:
return e

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="author" content="TS">
<meta name="copyright" content="page is under CC BY-NC-ND 3.0 CZ">
<meta name="generator" content="Spotter.ngo">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Chyba 404</title>
</head>
<body>
<h1>Stránka nebyla nalezena</h1>
<p>Stránka, kterou se pokoušíte zobrazit, nebyla na serveru nalezena. Zkontrolujte prosím URL v adresním řádku nebo se vraťte <a href="/">zpět na úvodní stránku</a>.</p>
</body>
</html>

View File

@ -6,10 +6,10 @@
<meta name="copyright" content="page is under CC BY-NC-ND 3.0 CZ">
<meta name="generator" content="Spotter.ngo">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Chyba</title>
<title>Chyba 502</title>
</head>
<body>
<h1>Chyba spojení</h1>
<h1>Chyba spojení s aplikací</h1>
<p>Aplikace ke které se pokoušíte připojit není dostupná. Nejspíše byla vypnuta správcem serveru.</p>
</body>
</html>