From 089259b6252b464c36bdf13dc37c2ded626a6c4e Mon Sep 17 00:00:00 2001
From: Julian Rother <julianr@fsmpi.rwth-aachen.de>
Date: Fri, 19 Aug 2016 03:59:11 +0200
Subject: [PATCH] Changed configuration to flasks native solution

---
 server.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/server.py b/server.py
index 5ca06ad..2442fcf 100755
--- a/server.py
+++ b/server.py
@@ -2,9 +2,10 @@
 from flask import Flask, render_template, g
 import mysql.connector
 import sqlite3
-import config
 
 app = Flask(__name__)
+config = app.config
+config.from_pyfile('config.py')
 
 # Row wrapper for sqlite
 def dict_factory(cursor, row):
@@ -17,15 +18,15 @@ def dict_factory(cursor, row):
 	return d
 
 def query(operation, *params):
-	if config.db_engine == 'mysql':
+	if config['DB_ENGINE'] == 'mysql':
 		if 'db' not in g or not g.db.is_connected():
-			g.db = mysql.connector.connect(user=config.db_user, password=config.db_passwd, host=config.db_host, database=config.db_db)
+			g.db = mysql.connector.connect(user=config['MYSQL_USER'], password=config['MYSQL_PASSWD'], host=config['MYSQL_HOST'], database=config['MYSQL_DB'])
 		cur = g.db.cursor(dictionary=True)
 		cur.execute(operation.replace('?', '%s'), params)
 		return cur.fetchall()
-	else:
+	elif config['DB_ENGINE'] == 'sqlite':
 		if 'db' not in g or not g.db.is_connected():
-			g.db = sqlite3.connect(config.db_file)
+			g.db = sqlite3.connect(config['SQLITE_DB'])
 			g.db.row_factory = dict_factory
 		cur = g.db.cursor()
 		cur.execute(operation, params)
@@ -57,5 +58,4 @@ def play():
 	return render_template('play.html',  active_page='play')
 
 if __name__ == '__main__':
-	app.debug = True
 	app.run()
-- 
GitLab