diff --git a/app.py b/app.py index c7a85290..cc6e43ad 100644 --- a/app.py +++ b/app.py @@ -86,7 +86,13 @@ class BaseView(HTTPMethodView): as_json = kwargs.pop('as_json') except KeyError: as_json = False - data = self.data(request, name, hash, **kwargs) + try: + data = self.data(request, name, hash, **kwargs) + except sqlite3.OperationalError as e: + data = { + 'ok': False, + 'error': str(e), + } if as_json: r = response.json(data) r.headers['Access-Control-Allow-Origin'] = '*' @@ -103,21 +109,7 @@ class BaseView(HTTPMethodView): return r -def sqlerrors(fn): - @wraps(fn) - async def inner(*args, **kwargs): - try: - return await fn(*args, **kwargs) - except sqlite3.OperationalError as e: - return response.json({ - 'ok': False, - 'error': str(e), - }) - return inner - - @app.route('/') -@sqlerrors async def index(request, sql=None): databases = ensure_build_metadata(True) return jinja.render( diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 00000000..6525c6eb --- /dev/null +++ b/templates/base.html @@ -0,0 +1,14 @@ + + + + {% block title %}{% endblock %} +{% block extra_head %}{% endblock %} + + +{% if error %} +
{{ error }}
+{% endif %} +{% block content %} +{% endblock %} + + diff --git a/templates/database.html b/templates/database.html index f5d36cf8..f8e62230 100644 --- a/templates/database.html +++ b/templates/database.html @@ -1,3 +1,8 @@ +{% extends "base.html" %} + +{% block title %}{{ database }}{% endblock %} + +{% block content %}

{{ database }}