server.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:ring-api 作者: sevaivanov 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号