本文整理汇总了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)
示例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)
示例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")
示例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)
示例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)
示例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
示例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])