diff --git a/basic/srv/spotter/appmgr/__init__.py b/basic/srv/spotter/appmgr/__init__.py index 7bce276..97d33aa 100644 --- a/basic/srv/spotter/appmgr/__init__.py +++ b/basic/srv/spotter/appmgr/__init__.py @@ -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 {{ diff --git a/basic/srv/spotter/appmgr/wsgiapp.py b/basic/srv/spotter/appmgr/wsgiapp.py index 7645757..5cb642a 100644 --- a/basic/srv/spotter/appmgr/wsgiapp.py +++ b/basic/srv/spotter/appmgr/wsgiapp.py @@ -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 diff --git a/basic/srv/spotter/templates/404.html b/basic/srv/spotter/templates/404.html new file mode 100644 index 0000000..364c4d6 --- /dev/null +++ b/basic/srv/spotter/templates/404.html @@ -0,0 +1,15 @@ + + +
+ + + + + +Stránka, kterou se pokoušíte zobrazit, nebyla na serveru nalezena. Zkontrolujte prosím URL v adresním řádku nebo se vraťte zpět na úvodní stránku.
+ + diff --git a/basic/srv/spotter/error.html b/basic/srv/spotter/templates/502.html similarity index 86% rename from basic/srv/spotter/error.html rename to basic/srv/spotter/templates/502.html index 692d977..7c17d66 100644 --- a/basic/srv/spotter/error.html +++ b/basic/srv/spotter/templates/502.html @@ -6,10 +6,10 @@ -Aplikace ke které se pokoušíte připojit není dostupná. Nejspíše byla vypnuta správcem serveru.