diff options
| author | 2018-02-21 09:30:05 +0000 | |
|---|---|---|
| committer | 2018-02-21 09:30:05 +0000 | |
| commit | ef8e96157f60ba0813cab72a90a6e8e92b44b6f0 (patch) | |
| tree | cbda21178338d3f992072d5f06e4ac4572e433f1 /pysite/views/error_handlers | |
| parent | adds initial unit testing (#22) (diff) | |
Rearrange views and templates
Diffstat (limited to 'pysite/views/error_handlers')
| -rw-r--r-- | pysite/views/error_handlers/http_404.py | 12 | ||||
| -rw-r--r-- | pysite/views/error_handlers/http_5xx.py | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/pysite/views/error_handlers/http_404.py b/pysite/views/error_handlers/http_404.py new file mode 100644 index 00000000..1d557d9b --- /dev/null +++ b/pysite/views/error_handlers/http_404.py @@ -0,0 +1,12 @@ +# coding=utf-8 +from werkzeug.exceptions import NotFound + +from pysite.base_route import ErrorView + + +class Error404View(ErrorView): + name = "error_404" + error_code = 404 + + def get(self, error: NotFound): + return "replace me with a template, 404 not found", 404 diff --git a/pysite/views/error_handlers/http_5xx.py b/pysite/views/error_handlers/http_5xx.py new file mode 100644 index 00000000..ed4d8d82 --- /dev/null +++ b/pysite/views/error_handlers/http_5xx.py @@ -0,0 +1,12 @@ +# coding=utf-8 +from werkzeug.exceptions import HTTPException + +from pysite.base_route import ErrorView + + +class Error404View(ErrorView): + name = "error_5xx" + error_code = range(500, 600) + + def get(self, error: HTTPException): + return "Internal server error. Please try again later!", error.code |