summaryrefslogtreecommitdiffstats
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rw-r--r--app.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/app.py b/app.py
index 304b843..9e38105 100644
--- a/app.py
+++ b/app.py
@@ -1,7 +1,7 @@
#!/usr/bin/python2
# -*- coding: utf-8 -*-
-import magic, os
+import magic, os, sys
from fit import Fit
from flask import Flask, render_template, request, flash, redirect, url_for
@@ -11,6 +11,10 @@ from werkzeug import secure_filename
from datetime import date
+# set default encoding to utf-8, otherwise pygit2 can not handle umlauts
+reload(sys)
+sys.setdefaultencoding('utf-8')
+
app = Flask(__name__)
app.config.from_pyfile('settings.py')
@@ -25,7 +29,7 @@ for i, study in enumerate(app.config['STUDIES'].items()):
for module in fit[abbr].get_modules():
# check if module is already listed
if all(map(lambda (k,v): v != module, modules)):
- slug = module.encode('ascii', errors='ignore')
+ slug = module.decode('ascii', errors='ignore')
app.config['STUDIES'][study[0]].append((slug, module))
class UploadForm(Form):
@@ -85,7 +89,7 @@ def upload(study, module = None):
year = form.year.data
filename = secure_filename(form.exam.data.filename)
- path = os.path.join(module,year,filename).encode('ascii', errors='ignore')
+ path = os.path.join(module,year,filename)
try:
oid = fit[study].add_file(form.exam.data.stream.getvalue(), path)