summaryrefslogtreecommitdiffstats
path: root/app.py
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2017-08-20 12:27:33 +0200
committerTharre <tharre3@gmail.com>2017-08-20 12:27:33 +0200
commit7054b67a4b19cd389cfaab5b0f564ba5c27f64e3 (patch)
treed0d6ef33ee6d3654f61b1409f6ee3c88a22f1f92 /app.py
parente6a9d58487ef36df78ea8dba5c2d2d411434b7bb (diff)
downloadalbion-api-7054b67a4b19cd389cfaab5b0f564ba5c27f64e3.tar.gz
albion-api-7054b67a4b19cd389cfaab5b0f564ba5c27f64e3.tar.xz
albion-api-7054b67a4b19cd389cfaab5b0f564ba5c27f64e3.zip
Create db in init_db() instead of __main__
If the application is run by i.e. uwsgi then __main__ is never called, and subsequently the database is not being created.
Diffstat (limited to 'app.py')
-rwxr-xr-xapp.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/app.py b/app.py
index ca9a7c8..410ad0d 100755
--- a/app.py
+++ b/app.py
@@ -15,6 +15,9 @@ DATABASE = 'db.sqlite3'
cache = SimpleCache()
def init_db():
+ if not os.path.isfile(DATABASE):
+ init_db()
+
with app.app_context():
db = get_db()
with app.open_resource('schema.sql', mode='r') as f:
@@ -130,7 +133,4 @@ def handle_404(error):
return make_response(jsonify({'error': 'Not found'}), 404)
if __name__ == '__main__':
- if not os.path.isfile(DATABASE):
- init_db()
-
app.run(host='0.0.0.0', debug=True)