本文整理汇总了Python中flask.ext.restplus.Api.init_app方法的典型用法代码示例。如果您正苦于以下问题:Python Api.init_app方法的具体用法?Python Api.init_app怎么用?Python Api.init_app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.ext.restplus.Api
的用法示例。
在下文中一共展示了Api.init_app方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Flask
# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import init_app [as 别名]
#!bin/python
from flask import Flask, Blueprint
from flask.ext.restplus import Api, Resource, fields, apidoc
app = Flask(__name__)
# PREFIX van de api -> http://SERVERNAME/<URL_PREFIX>
blueprint = Blueprint('api', __name__, url_prefix='/apiv1')
# CUSTOM CREATE van Api object ipv api = Api(blueprint, ui=False)
api = Api()
# manuele add van endpoint specs met path naar swagger.json, anders auto op /apiv1/swagger.json
# AANPASSEN PATH->swagger.json naar /<NAMESPACE>/swagger.json
api.add_resource(api.swagger_view(), '/sensoren/swagger.json', endpoint='specs', doc=False)
# !!! Blueprint is een soort app. Aangezien de routes gekoppeld zijn ad blueprint, moet deze geregistreerd worden, dus niet api.init_app(app, add_specs=False, ui=False)
# init Api
api.init_app(blueprint, add_specs=False, ui=False)
# NAMESPACE: AANPASSEN! Komt overeen met http://<SERVERNAME>/URL_PREFIX/<NAMESPACE>
ns = api.namespace('sensoren', description='Temperatuursensoren Koelcel & Diepvriescel')
# PATH NAAR SWAGGER (/<NAMESPACE>/swagger)
@blueprint.route('/sensoren/swagger/', endpoint='swagger')
def swagger_ui():
return apidoc.ui_for(api)
# EFFECTIEVE API GEDEELTE
# => http://<SERVERNAME>/URL_PREFIX/<NAMESPACE>/
@ns.route('/', endpoint='sensoren')
@api.doc(description='test')
class MyResource(Resource):
def get(self):