summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-03-22 21:35:23 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-03-22 21:39:00 -0700
commitd64e403646393089214675e45fba801c2436e4d2 (patch)
treedc3a5fecd829d544395919af235c97ec6007aa38
parentd4a287d4fc72bd68d41a7add042ae064bae4aa75 (diff)
downloadfatcat-d64e403646393089214675e45fba801c2436e4d2.tar.gz
fatcat-d64e403646393089214675e45fba801c2436e4d2.zip
make it run
-rw-r--r--config.py8
-rwxr-xr-x[-rw-r--r--]run.py17
2 files changed, 22 insertions, 3 deletions
diff --git a/config.py b/config.py
new file mode 100644
index 00000000..bad871dc
--- /dev/null
+++ b/config.py
@@ -0,0 +1,8 @@
+
+import os
+basedir = os.path.abspath(os.path.dirname(__file__))
+
+class Config(object):
+ SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') or \
+ 'sqlite:///' + os.path.join(basedir, 'fatcat_dev.sqlite')
+ SQLALCHEMY_TRACK_MODIFICATIONS = False
diff --git a/run.py b/run.py
index c8f492ea..512d5828 100644..100755
--- a/run.py
+++ b/run.py
@@ -1,5 +1,7 @@
+#!/usr/bin/env python3
import argparse
+import fatcat.sql
from fatcat import app, db
def main():
@@ -15,12 +17,21 @@ def main():
default=8040,
help="listen on this port")
parser.add_argument('--database-uri',
- default=app.config['DATABASE_URI'],
+ default=app.config['SQLALCHEMY_DATABASE_URI'],
help="sqlalchemy database string")
+ parser.add_argument('--init-db',
+ action='store_true',
+ help="create database tables and insert dummy data")
args = parser.parse_args()
- app.config['DATABASE_URI'] = args.database_uri
- db.create_all()
+ app.config['SQLALCHEMY_DATABASE_URI'] = args.database_uri
+
+ if args.init_db:
+ db.create_all()
+ fatcat.sql.populate_db()
+ print("Dummy database configured: " + app.config['SQLALCHEMY_DATABASE_URI'])
+ return
+
app.run(debug=args.debug, host=args.host, port=args.port)
if __name__ == '__main__':