当前位置: 首页>>代码示例>>Python>>正文


Python flask_sockets.Sockets方法代码示例

本文整理汇总了Python中flask_sockets.Sockets方法的典型用法代码示例。如果您正苦于以下问题:Python flask_sockets.Sockets方法的具体用法?Python flask_sockets.Sockets怎么用?Python flask_sockets.Sockets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_sockets的用法示例。


在下文中一共展示了flask_sockets.Sockets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_app

# 需要导入模块: import flask_sockets [as 别名]
# 或者: from flask_sockets import Sockets [as 别名]
def create_app(sub_mgr, schema, options):
    app = Flask(__name__)
    sockets = Sockets(app)

    app.app_protocol = lambda environ_path_info: 'graphql-subscriptions'

    app.add_url_rule(
        '/graphql',
        view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))

    @app.route('/publish', methods=['POST'])
    def sub_mgr_publish():
        sub_mgr.publish(*request.get_json())
        return jsonify(request.get_json())

    @sockets.route('/socket')
    def socket_channel(websocket):
        subscription_server = SubscriptionServer(sub_mgr, websocket, **options)
        subscription_server.handle()
        return []

    return app 
开发者ID:hballard,项目名称:graphql-python-subscriptions,代码行数:24,代码来源:test_subscription_transport.py

示例2: create_app

# 需要导入模块: import flask_sockets [as 别名]
# 或者: from flask_sockets import Sockets [as 别名]
def create_app(self, testing):
        self.app = Flask("fastlane")

        self.testing = testing
        self.app.testing = testing
        self.app.error_handlers = []

        for key in self.config.items.keys():
            self.app.config[key] = self.config[key]

        self.app.config["ENV"] = self.config.ENV
        self.app.config["DEBUG"] = self.config.DEBUG
        self.app.original_config = self.config
        self.app.log_level = self.log_level
        self.configure_logging()
        self.connect_redis()
        self.configure_queue()
        #  self.connect_queue()
        self.config_blacklist_words_fn()

        self.configure_basic_auth()
        self.connect_db()
        self.load_executor()
        self.load_error_handlers()

        enable_cors = self.app.config["ENABLE_CORS"]

        if (
            isinstance(enable_cors, (str, bytes)) and enable_cors.lower() == "true"
        ) or (isinstance(enable_cors, (bool)) and enable_cors):
            origin = self.app.config["CORS_ORIGINS"]
            self.app.logger.info(f"Configured CORS to allow access from '{origin}'.")
            CORS(self.app)

        metrics.init_app(self.app)
        self.app.register_blueprint(metrics.bp)
        self.app.register_blueprint(healthcheck)
        self.app.register_blueprint(enqueue)
        self.app.register_blueprint(task_api)
        self.app.register_blueprint(execution_api)
        self.app.register_blueprint(status)
        self.app.register_blueprint(routes_api)

        self.app.register_blueprint(gzipped.bp)
        gzipped.init_app(self.app)

        sockets = Sockets(self.app)
        sockets.register_blueprint(stream) 
开发者ID:fastlane-queue,项目名称:fastlane,代码行数:50,代码来源:app.py

示例3: instantiate_app_with_views

# 需要导入模块: import flask_sockets [as 别名]
# 或者: from flask_sockets import Sockets [as 别名]
def instantiate_app_with_views(context):
    app = Flask(
        'dagster-ui',
        static_url_path='',
        static_folder=os.path.join(os.path.dirname(__file__), './webapp/build'),
    )
    sockets = Sockets(app)
    app.app_protocol = lambda environ_path_info: 'graphql-ws'

    schema = create_schema()
    subscription_server = DagsterSubscriptionServer(schema=schema)

    app.add_url_rule(
        '/graphql',
        'graphql',
        DagsterGraphQLView.as_view(
            'graphql',
            schema=schema,
            graphiql=True,
            # XXX(freiksenet): Pass proper ws url
            graphiql_template=PLAYGROUND_TEMPLATE,
            executor=Executor(),
            context=context,
        ),
    )
    app.add_url_rule('/graphiql', 'graphiql', lambda: redirect('/graphql', 301))
    sockets.add_url_rule(
        '/graphql', 'graphql', dagster_graphql_subscription_view(subscription_server, context)
    )

    app.add_url_rule(
        # should match the `build_local_download_url`
        '/download/<string:run_id>/<string:step_key>/<string:file_type>',
        'download_view',
        download_view(context),
    )

    # these routes are specifically for the Dagit UI and are not part of the graphql
    # API that we want other people to consume, so they're separate for now.
    # Also grabbing the magic global request args dict so that notebook_view is testable
    app.add_url_rule('/dagit/notebook', 'notebook', lambda: notebook_view(request.args))

    app.add_url_rule('/dagit_info', 'sanity_view', info_view)
    app.register_error_handler(404, index_view)
    CORS(app)
    return app 
开发者ID:dagster-io,项目名称:dagster,代码行数:48,代码来源:app.py


注:本文中的flask_sockets.Sockets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。