summaryrefslogtreecommitdiffstats
path: root/python/run.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-16 18:34:19 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-16 18:34:19 -0700
commit4cf667c283d54f769e73d76bb23bbb68b4329cf8 (patch)
tree4bbeb1cdeb053c09e86e2cc41962382bcb837729 /python/run.py
parentb2d5968e0a7ac5576782f54980c930345f4c5298 (diff)
downloadfatcat-4cf667c283d54f769e73d76bb23bbb68b4329cf8.tar.gz
fatcat-4cf667c283d54f769e73d76bb23bbb68b4329cf8.zip
move python code to subdirectory
Diffstat (limited to 'python/run.py')
-rwxr-xr-xpython/run.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/python/run.py b/python/run.py
new file mode 100755
index 00000000..0fbd6194
--- /dev/null
+++ b/python/run.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+import argparse
+import fatcat.sql
+from fatcat import app, db
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--debug',
+ action='store_true',
+ help="enable debugging interface (note: not for everything)")
+ parser.add_argument('--host',
+ default="127.0.0.1",
+ help="listen on this host/IP")
+ parser.add_argument('--port',
+ type=int,
+ default=8040,
+ help="listen on this port")
+ parser.add_argument('--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['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__':
+ main()