aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_webface.py
blob: cfddad48be66dc94612eac08e8a17877aa18c5b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3

import argparse
from fatcat import app

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=9810,
        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()