def __init__(self, host, http_port, ws_port,
ws_poll_interval, dring, verbose):
self.host = host
self.http_port = http_port
self.ws_port = ws_port
self.ws_poll_interval = ws_poll_interval
self.dring = dring
self.verbose = verbose
# Flask Application
self.app = Flask(__name__)
self.app.config['SECRET_KEY'] = 't0p_s3cr3t'
self.app.config.update(PROPAGATE_EXCEPTIONS=True)
# Flask Restuful API
self.api = Api(
app=self.api_blueprint,
prefix=self.API_URL_PREFIX,
catch_all_404s=True
)
# Cross Origin Resource Sharing is needed to define response headers
# to allow HTTP methods from in-browser Javascript because accessing
# a different port is considered as accessing a different domain
self.api.decorators = [
cors.crossdomain(
origin='*',
methods=['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS'],
attach_to_all=True,
automatic_options=True
)
]
self._init_api_resources()
self.app.register_blueprint(self.api_blueprint)
# Websockets
self._init_websockets()
self._register_callbacks()
评论列表
文章目录