-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
50 lines (37 loc) · 1.11 KB
/
Copy pathapp.py
File metadata and controls
50 lines (37 loc) · 1.11 KB
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
41
42
43
44
45
46
47
48
49
50
import os
import sys
from flask import Flask
from flask_cors import CORS
from database import db
from security import configure_authentication
from config import Config
from routes import pages
from models import User
sys.path.append(os.path.dirname(__name__))
# flask setup
def create_app():
app = Flask(__name__)
app.config.from_object(Config)
db.init_app(app)
with app.app_context():
db.create_all()
# register admin user automatically
try:
admin_phone = open("/run/secrets/admin_phone", "r").read().strip()
admin_password = open("/run/secrets/admin_password", "r").read().strip()
admin = User(username='admin', phone=admin_phone)
admin.set_password(admin_phone, admin_password)
db.session.add(admin)
db.session.commit()
except Exception:
pass
configure_authentication(app)
# routing blueprint
app.register_blueprint(pages)
CORS(app)
return app
if __name__ == '__main__':
app = create_app()
# init_database(app)
app.run(host='0.0.0.0')
# app.run()