當前位置: 首頁>>代碼示例>>Python>>正文


Python blueprints.Blueprint方法代碼示例

本文整理匯總了Python中flask.blueprints.Blueprint方法的典型用法代碼示例。如果您正苦於以下問題:Python blueprints.Blueprint方法的具體用法?Python blueprints.Blueprint怎麽用?Python blueprints.Blueprint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask.blueprints的用法示例。


在下文中一共展示了blueprints.Blueprint方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _sanic_handler

# 需要導入模塊: from flask import blueprints [as 別名]
# 或者: from flask.blueprints import Blueprint [as 別名]
def _sanic_handler(self):
        from sanic import response
        from sanic.blueprints import Blueprint

        swagger_blueprint = Blueprint('swagger_blueprint', url_prefix=self._url_prefix)

        @swagger_blueprint.get('/')
        async def swagger_blueprint_doc_handler(request):
            return response.html(self.doc_html)

        if self._editor:
            @swagger_blueprint.get('/editor')
            async def swagger_blueprint_editor_handler(request):
                return response.html(self.editor_html)

        @swagger_blueprint.get('/swagger.json')
        async def swagger_blueprint_config_handler(request):
            return response.json(self.get_config(request.host))

        swagger_blueprint.static('/', str(self.static_dir))
        self._app.blueprint(swagger_blueprint) 
開發者ID:PWZER,項目名稱:swagger-ui-py,代碼行數:23,代碼來源:core.py

示例2: _quart_handler

# 需要導入模塊: from flask import blueprints [as 別名]
# 或者: from flask.blueprints import Blueprint [as 別名]
def _quart_handler(self):
        from quart import Blueprint, request
        from quart.json import jsonify

        swagger_blueprint = Blueprint(
            'swagger_blueprint', __name__, url_prefix=self._url_prefix,
            static_url_path='', static_folder='', root_path=self.static_dir
        )

        @swagger_blueprint.route('/', methods=['GET'])
        async def swagger_blueprint_doc_handler():
            return self.doc_html

        if self._editor:
            @swagger_blueprint.route('/editor', methods=['GET'])
            async def swagger_blueprint_editor_handler():
                return self.editor_html

        @swagger_blueprint.route('/swagger.json', methods=['GET'])
        async def swagger_blueprint_config_handler():
            return jsonify(self.get_config(request.host))

        self._app.register_blueprint(blueprint=swagger_blueprint, url_prefix=self._url_prefix) 
開發者ID:PWZER,項目名稱:swagger-ui-py,代碼行數:25,代碼來源:core.py

示例3: apply_blueprint_to_app

# 需要導入模塊: from flask import blueprints [as 別名]
# 或者: from flask.blueprints import Blueprint [as 別名]
def apply_blueprint_to_app(self, app):
        """
        Applies a blueprint to the app, to support invocation from this executor.
        """
        testbp = Blueprint("testbp", __name__)

        def build_invoker(fn_name, fn):
            path = "/" + fn_name

            @testbp.route(path, methods=["POST"], endpoint=fn_name)
            def _(**kwargs):
                arg_values = request.get_json()["args"]
                return fn(*arg_values)

        for fn_name, fn in self.funcs.items():
            build_invoker(fn_name, fn)

        app.register_blueprint(testbp, url_prefix="/__test") 
開發者ID:quay,項目名稱:quay,代碼行數:20,代碼來源:liveserverfixture.py

示例4: register_routes

# 需要導入模塊: from flask import blueprints [as 別名]
# 或者: from flask.blueprints import Blueprint [as 別名]
def register_routes(app):
    """Register routes."""
    from . import controllers
    from flask.blueprints import Blueprint

    for module in _import_submodules_from_package(controllers):
        bp = getattr(module, 'bp')
        if bp and isinstance(bp, Blueprint):
            app.register_blueprint(bp) 
開發者ID:Akagi201,項目名稱:learning-python,代碼行數:11,代碼來源:__init__.py

示例5: _flask_handler

# 需要導入模塊: from flask import blueprints [as 別名]
# 或者: from flask.blueprints import Blueprint [as 別名]
def _flask_handler(self):
        from flask import request, jsonify
        from flask.blueprints import Blueprint

        swagger_blueprint = Blueprint(
            'swagger_blueprint', __name__, url_prefix=self._url_prefix,
            static_folder=self.static_dir, static_url_path='/'
        )

        @swagger_blueprint.route(r'')
        def swagger_blueprint_doc_handler():
            return self.doc_html

        @swagger_blueprint.route(r'/')
        def swagger_blueprint_doc_v2_handler():
            return self.doc_html

        @swagger_blueprint.route(r'/swagger.json')
        def swagger_blueprint_config_handler():
            return jsonify(self.get_config(request.host))

        if self._editor:
            @swagger_blueprint.route(r'/editor')
            def swagger_blueprint_editor_handler():
                return self.editor_html

        self._app.register_blueprint(swagger_blueprint) 
開發者ID:PWZER,項目名稱:swagger-ui-py,代碼行數:29,代碼來源:core.py

示例6: register

# 需要導入模塊: from flask import blueprints [as 別名]
# 或者: from flask.blueprints import Blueprint [as 別名]
def register(self):
        blueprint = Blueprint("index", __name__, template_folder="templates")
        blueprint.add_url_rule("/", "default", self.render_default)
        blueprint.add_url_rule("/data", "data", self.render_data)
        blueprint.add_url_rule("/graph", "graph", self.render_graph)
        blueprint.add_url_rule("/graph.json", "graph_data", self.render_graph_data)
        blueprint.add_url_rule("/ble", "ble", self.render_ble)
        blueprint.add_url_rule("/serial", "serial", self.render_serial)
        blueprint.context_processor(self.fill)
        return blueprint 
開發者ID:kolinger,項目名稱:rd-usb,代碼行數:12,代碼來源:index.py

示例7: register_blueprints

# 需要導入模塊: from flask import blueprints [as 別名]
# 或者: from flask.blueprints import Blueprint [as 別名]
def register_blueprints(app):
    for item in getmembers(api.views):
        if item[0].startswith("blueprint") and isinstance(item[1], Blueprint):
            app.register_blueprint(item[1]) 
開發者ID:pycook,項目名稱:cmdb,代碼行數:6,代碼來源:app.py


注:本文中的flask.blueprints.Blueprint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。