diff --git a/cps/static/css/style.css b/cps/static/css/style.css
index 16c3cb36..9e2e82b3 100644
--- a/cps/static/css/style.css
+++ b/cps/static/css/style.css
@@ -5,6 +5,22 @@
src: local('Grand Hotel'), local('GrandHotel-Regular'), url("fonts/GrandHotel-Regular.ttf") format('truetype');
}
+html.http-error {
+ margin: 0;
+ height: 100%;
+}
+.http-error body {
+ margin: 0;
+ height: 100%;
+ display: table;
+ width: 100%;
+}
+.http-error body > div {
+ display: table-cell;
+ vertical-align: middle;
+ text-align: center;
+}
+
body{background:#f2f2f2}body h2{font-weight:normal;color:#444}
body { margin-bottom: 40px;}
a{color: #45b29d}a:hover{color: #444;}
diff --git a/cps/templates/http_error.html b/cps/templates/http_error.html
new file mode 100644
index 00000000..8167ddf3
--- /dev/null
+++ b/cps/templates/http_error.html
@@ -0,0 +1,26 @@
+
+
+
+ {{ instance }} | HTTP Error ({{ error_code }})
+
+
+
+
+
+
+
+
+
+
+ {% if g.user.get_theme == 1 %}
+
+ {% endif %}
+
+
+
+
{{ error_code }}
+
{{ error_name }}
+
{{_('Back to home')}}
+
+
+
diff --git a/cps/web.py b/cps/web.py
index c93ca00d..cc2a8c86 100644
--- a/cps/web.py
+++ b/cps/web.py
@@ -42,6 +42,8 @@ from flask import (Flask, render_template, request, Response, redirect,
abort, Markup)
from flask import __version__ as flaskVersion
from werkzeug import __version__ as werkzeugVersion
+from werkzeug.exceptions import default_exceptions
+
from jinja2 import __version__ as jinja2Version
import cache_buster
import ub
@@ -176,6 +178,20 @@ mimetypes.add_type('application/x-cbt', '.cbt')
mimetypes.add_type('image/vnd.djvu', '.djvu')
app = (Flask(__name__))
+
+
+def error_http(error):
+ return render_template('http_error.html',
+ error_code=error.code,
+ error_name=error.name,
+ instance=config.config_calibre_web_title
+ ), error.code
+
+
+# http error handling
+for ex in default_exceptions:
+ app.register_error_handler(ex, error_http)
+
app.wsgi_app = ReverseProxied(app.wsgi_app)
cache_buster.init_cache_busting(app)