diff options
author | Tharre <tharre3@gmail.com> | 2017-08-20 12:27:33 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2017-08-20 12:27:33 +0200 |
commit | 7054b67a4b19cd389cfaab5b0f564ba5c27f64e3 (patch) | |
tree | d0d6ef33ee6d3654f61b1409f6ee3c88a22f1f92 /app.py | |
parent | e6a9d58487ef36df78ea8dba5c2d2d411434b7bb (diff) | |
download | albion-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-x | app.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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) |