forked from saltshaker-plus/saltshaker_api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
38 lines (30 loc) · 1.1 KB
/
app.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
# -*- coding:utf-8 -*-
from flask import Flask
from common.cli import initialize
import click
from flask_cors import CORS
from tasks.tasks_conf import CELERY_BROKER_URL
from extensions import celery, scheduler, aps_listener
from router import api
app = Flask(__name__)
# 跨域访问
CORS(app, supports_credentials=True, resources={r"*": {"origins": "*"}})
# flask_restful init
api.init_app(app)
# celery init
app.config['CELERY_BROKER_URL'] = CELERY_BROKER_URL
celery.init_app(app)
# app.config.from_object(Config())
# scheduler.init_app(app)
scheduler.add_listener(aps_listener)
scheduler.start()
@app.cli.command()
@click.option('--username', prompt='Enter the initial administrators username', default='admin',
help="Enter the initial username")
@click.option('--password', prompt='Enter the initial Administrators password', hide_input=True,
confirmation_prompt=True, help="Enter the initial password")
def init(username, password):
"""Initialize the saltshaker_plus."""
initialize(username, password)
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0", port=9000)