summaryrefslogtreecommitdiffstats
path: root/app/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/__init__.py')
-rw-r--r--app/__init__.py48
1 files changed, 6 insertions, 42 deletions
diff --git a/app/__init__.py b/app/__init__.py
index 6c6b08c..7022d2b 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -2,10 +2,6 @@
from flask import Flask, render_template, g
from .main import main
-from .backend import Storage
-import sys
-reload(sys)
-sys.setdefaultencoding('utf-8')
def create_app(config=None):
"""Creates the Flask app."""
@@ -13,10 +9,8 @@ def create_app(config=None):
configure_app(app)
configure_error_handlers(app)
- init_app(app)
- for blueprint in [main]:
- app.register_blueprint(blueprint)
+ app.register_blueprint(main)
return app
@@ -36,43 +30,13 @@ def configure_app(app):
app.logger.addHandler(file_handler)
-def init_app(app):
- import os
- @app.before_request
- def init():
- g.studies = {}
- for i, study in enumerate(app.config['STUDIES'].items()):
- abbr = study[0]
- g.studies[abbr] = Storage(os.path.join('app', 'static','studies', abbr))
-
- modules = app.config['STUDIES'][study[0]]
- # extend module list with git values
- for module in g.studies[abbr].get_modules():
- # check if module is already listed
- if all(map(lambda (k,v): v != module, modules)):
- slug = module.decode('ascii', errors='ignore')
- app.config['STUDIES'][study[0]].append((slug, module))
-
-
-## populate Module-List
-#fit = {}
-#for i, study in enumerate(app.config['STUDIES'].items()):
-# abbr = study[0]
-# fit[abbr] = Fit(os.path.join('static','studies',abbr + '.git'))
-#
-# modules = app.config['STUDIES'][study[0]]
-# # extend module list with git values
-# for module in fit[abbr].get_modules():
-# # check if module is already listed
-# if all(map(lambda (k,v): v != module, modules)):
-# slug = module.decode('ascii', errors='ignore')
-# app.config['STUDIES'][study[0]].append((slug, module))
-
def configure_error_handlers(app):
@app.route('/forbidden')
- @app.errorhandler(400)
@app.errorhandler(403)
+ def forbidden(e):
+ return render_template('403.html', error=e), e.code
+
+ @app.errorhandler(400)
@app.errorhandler(404)
def errorhandler(e):
- return render_template('error.html', error=e), e.code
-
+ return render_template('404.html', error=e), e.code