forked from web-platform-tests/pulls.web-platform-tests.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
40 lines (32 loc) · 1.22 KB
/
manage.py
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
38
39
40
import configparser
from flask import Flask
from wptdash.database import db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
import wptdash.models as models
CONFIG = configparser.ConfigParser()
CONFIG.readfp(open(r'config.txt'))
WPTDASH_DB = CONFIG.get('postgresql', 'WPTDASH_DB')
WPTDASH_DB_USER = CONFIG.get('postgresql', 'WPTDASH_DB_USER')
WPTDASH_DB_PASS = CONFIG.get('postgresql', 'WPTDASH_DB_PASS')
WPTDASH_DB_HOST = CONFIG.get('postgresql', 'WPTDASH_DB_HOST')
# This is here to not-break existing installations
if WPTDASH_DB_HOST == "":
WPTDASH_DB_HOST = "localhost"
WPTDASH_DB_URI = 'postgresql://%s:%s@%s/%s' % (WPTDASH_DB_USER,
WPTDASH_DB_PASS,
WPTDASH_DB_HOST,
WPTDASH_DB)
app = Flask(__name__)
app.config.update(dict(
DEBUG=True,
SQLALCHEMY_TRACK_MODIFICATIONS=False,
SQLALCHEMY_DATABASE_URI=WPTDASH_DB_URI
))
app.config.from_envvar('WPTDASH_SETTINGS', silent=True)
db.init_app(app)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()