From 761a55d80fc0b94b92f0c52a04407c89871ffbb5 Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Tue, 11 Oct 2016 17:58:02 +0200 Subject: [PATCH] Implemented auto-generation of a static 500-Page --- .gitignore | 1 + config.py.example | 1 + server.py | 12 ++++++++++-- templates/500.html | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index efa84b9..bf258de 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ config.py __pycache__ *.sqlite files/* +static/500.html diff --git a/config.py.example b/config.py.example index 289983e..ec3ed60 100644 --- a/config.py.example +++ b/config.py.example @@ -20,3 +20,4 @@ SQLITE_INIT_DATA = False #LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de' #ICAL_URL = 'https://user:password@mail.fsmpi.rwth-aachen.de/SOGo/....ics' +ERROR_PAGE = 'static/500.html' diff --git a/server.py b/server.py index 7af9cda..95ee495 100644 --- a/server.py +++ b/server.py @@ -179,6 +179,16 @@ def handle_internal_error(e): traceback.print_exc() return render_template('500.html') +@sched_func(5*60, firstdelay=0) +def dump_error_page(): + if 'ERROR_PAGE' not in config: + return + request.url_rule = Rule(request.path, endpoint='handle_internal_error') + text = render_template('500.html') + f = open(config['ERROR_PAGE'], 'w') + f.write(text) + f.close() + # debian ships jinja2 without this test... @app.template_test(name='equalto') def equalto(a,b): @@ -426,7 +436,6 @@ def edit(prefix='', ignore=[]): @app.route('/new/<table>', methods=['GET', 'POST']) @mod_required def create(table): - print(table, request.values) assert table in tabs defaults = {'created_by': session['user']['dbid'], 'time_created': datetime.now(), 'time_updated': datetime.now()} columns = [] @@ -445,7 +454,6 @@ def create(table): assert column not in defaults columns.append(column) values.append(val) - print(columns, values) id = modify('INSERT INTO %s (%s) VALUES (%s)'%(tabs[table][0], ','.join(columns), ','.join(['?']*len(values))), *values) if 'ref' in request.values: diff --git a/templates/500.html b/templates/500.html index f9d663d..d47abf8 100644 --- a/templates/500.html +++ b/templates/500.html @@ -2,7 +2,7 @@ {% block content %} <div class="panel panel-danger"> <div class="panel-heading"> - <h1 class="panel-title">Interner Fehler (500)</h1> + <h1 class="panel-title">Interner Fehler</h1> </div> <div class="row panel-body"> <div class="col-xs-12"> -- GitLab