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


Python Api.namespace方法代码示例

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


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

示例1: Flask

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask
from flask.ext.restplus import Api


app = Flask(__name__)
app.config.SWAGGER_UI_DOC_EXPANSION = 'list'
api = Api(app, version='1.0', title='AI API', description='A simple API for AI class project')

tsp = api.namespace('tsp', description='TSP API')
开发者ID:jpowie01,项目名称:TSP-NN-API,代码行数:11,代码来源:api.py

示例2: Flask

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
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):
        return "Hello!"

model = api.model('Model', {
开发者ID:KunstencentrumVooruit,项目名称:flask_swagger,代码行数:33,代码来源:template.py

示例3: not_implemented

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
# Common

errorResponseModel = api.model('Error', generalSchemas.basic_error_response)

def not_implemented():
    result = {'error':'not_implemented', 'description':'Feature not implemented yet'}
    return result, 500

def not_found():
    result = {'error':'not_found', 'description':'Resource not found'}
    return result, 404

# Extra routes

extra_ns = api.namespace('extra', description='Some extra functions.')

@extra_ns.route('/purge')
class Purge(Resource):

    @api.doc(description='Purge all data: contexts, compositions, files, etc.')
    def get(self):
        return managementOps.purge(datastore)

@extra_ns.route('/tokens')
class Tokens(Resource):

    @api.doc(description='Get all tokens in datastore.')
    def get(self):
        return managementOps.getAllTokens(datastore)
开发者ID:CloudOpting,项目名称:cloudopting-crane,代码行数:31,代码来源:commander.py

示例4: Flask

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask
from flask.ext.restplus import Api
from flask.ext.restplus import fields
from sklearn.externals import joblib

app = Flask(__name__)

api = Api(
   app, 
   version='1.0', 
   title='Credit API',
   description='A simple Prediction API')

ns = api.namespace('approve_credit', 
   description='Approve Credit Operations')
开发者ID:fclesio,项目名称:learning-space,代码行数:17,代码来源:setup_flask.py

示例5: Flask

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask
from flask.ext.restplus import Api

app = Flask("dmon-agent")
api = Api(app, version='0.0.4', title='DICE Monitoring Agent API',
          description="RESTful API for the DICE Monitoring Platform  Agent (dmon-agent)",
          )


# changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1
agent = api.namespace('agent', description='dmon agent operations')
开发者ID:ioan-dragan,项目名称:DICE-Project,代码行数:13,代码来源:app.py

示例6: Blueprint

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask, Blueprint
from flask.ext.restplus import Api, Resource, fields

api_v1 = Blueprint('api', __name__, url_prefix='/api/1')

api = Api(api_v1, version='1.0', title='Todo API',
    description='A simple TODO API',
)

ns = api.namespace('todos', description='TODO operations')

TODOS = {
    'todo1': {'task': 'build an API'},
    'todo2': {'task': '?????'},
    'todo3': {'task': 'profit!'},
}

todo = api.model('Todo', {
    'task': fields.String(required=True, description='The task details')
})

listed_todo = api.model('ListedTodo', {
    'id': fields.String(required=True, description='The todo ID'),
    'todo': fields.Nested(todo, description='The Todo')
})


def abort_if_todo_doesnt_exist(todo_id):
    if todo_id not in TODOS:
        api.abort(404, "Todo {} doesn't exist".format(todo_id))
开发者ID:Dlotan,项目名称:flask-restplus,代码行数:32,代码来源:todo_blueprint.py

示例7: Blueprint

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
# -*- coding: utf-8 -*-
from flask.ext.restplus import apidoc, Api
from flask import Blueprint, render_template
from flask_cors import cross_origin

api_blueprint = Blueprint('api', __name__)
api = Api(api_blueprint, doc=False, catch_all_404s=True,
        title='API version 2.0')

ns_administrative = api.namespace('administrative',
        description="Administrative APIs", path='/')

def init_app(app):
    from . import hail, taxi, ads, drivers, zupc, profile, vehicle, documents
    api.init_app(app, add_specs=False)
    app.register_blueprint(api_blueprint)
    app.register_blueprint(apidoc.apidoc)

    @app.route('/swagger.json', endpoint='api.specs')
    @cross_origin()
    def swagger():
        return render_template('swagger.json', host=app.config['SERVER_NAME']), 200,
    {'Content-Type': 'application/json'}
开发者ID:fabmob,项目名称:APITaxi,代码行数:25,代码来源:__init__.py

示例8: Flask

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask, jsonify, request
from flask.ext.restplus import Api, Resource, fields
from flask import send_from_directory
import shutil


app = Flask("D-MON")
api = Api(app, version='0.2.5', title='DICE MONitoring API',
    description='RESTful API for the DICE Monitoring Platform  (D-MON)',
)

backProc = None

#changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1
dmon = api.namespace('dmon', description='D-MON operations')
开发者ID:dice-project,项目名称:DICE-Monitoring,代码行数:17,代码来源:app.py

示例9: Flask

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.restplus import Api

app = Flask(__name__)
app.config.from_object("config.config")
api = Api(app, version=app.config["VERSION"], title="api title", description="Api description")
namespace = api.namespace(app.config["URL_PREFIX"], description="version api")

db = SQLAlchemy(app)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command("db", MigrateCommand)

from app.users import userDb, users, login
from app.transactions import send
开发者ID:sergicollado,项目名称:simpleFlaskSeed,代码行数:20,代码来源:__init__.py

示例10: controller_error

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
    result = {'error':'process_error', 'description':'Error while processing request.'}
    if GENERAL_DEBUG:
        result['description'] = result['description']+' '+text
    return result, 500

def controller_error(text):
    result = {'error':'controller_error', 'description':text}
    return result, 400

def not_started():
    result = {'error':'not_started', 'description':'The process has not stated yet.'}
    return result, 400

# Install

install_ns = api.namespace('install', description='Install operations.')

@install_ns.route('/docker')
class DockerInst(Resource):
    @api.doc(description='Install docker daemon')
    @api.response(500, 'Error processing the request', errorResponseModel)
    @api.response(200, 'OK', generalResponseModel)
    def get(self):
        try:
            return Installator.docker()
        except ControllerError as e:
            return controller_error(e.message)
        except Exception as e:
            return process_error(str(e))

@install_ns.route('/crane')
开发者ID:hploscar,项目名称:comcloud-node-agent,代码行数:33,代码来源:main.py

示例11: import

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask, Blueprint, jsonify, render_template
from flask.ext.restplus import Resource, fields, Api, apidoc
from flask.ext.assets import Environment, Bundle
from rcssmin import cssmin

from kumo import geojson
from kumo.query import (DEFAULT_LIMIT, station, stations, by_country, countries,
                        is_station_id)

app = Flask(__name__, static_folder='assets')
app.config.SWAGGER_UI_DOC_EXPANSION = 'list'
blueprint = Blueprint('api', __name__, url_prefix='/api')
api = Api(blueprint, ui=False, title='Kumo',
          description='API to request air quality measuring stations')
ns_station = api.namespace('stations', description='Get stations from ID')
ns_country = api.namespace('countries', description='Get stations from countries')


js_assets = (
    'bower/jquery/dist/jquery.js',
    'bower/bootstrap/dist/js/bootstrap.js',
    'bower/leaflet/dist/leaflet.js',
    'bower/leaflet-filelayer/leaflet.filelayer.js',
    'js/main.js',
)

css_assets = (
    'bower/bootstrap/dist/css/bootstrap.min.css',
    'bower/fontawesome/css/font-awesome.min.css',
    'bower/leaflet/dist/leaflet.css',
开发者ID:garaud,项目名称:kumo,代码行数:32,代码来源:app.py

示例12: Flask

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
from flask import Flask
from flask.ext.restplus import Api, Resource, fields

app = Flask(__name__)
api = Api(app, version='1.0', title='Resume Generator API',
    description='An API used to integrate resume information from various formats and transform them into different graphical representations.')

ns = api.namespace('resumes', description='Resumes')

resume_parser = api.parser()
resume_parser.add_argument('username', type=str, required=True, help='Your username, used as an identifier for any request to the API', location='form')
resume_parser.add_argument('fullname', type=str, required=True, help='Your full name', location='form')
resume_parser.add_argument('age',      type=int, required=True, help='Your age', location='form')

resume = api.model('Resume', {
  'username': fields.String(required=True),
  'fullname': fields.String(required=True),
  'age'     : fields.Integer(required=True)
})

SUPPORTED_INPUTS = ['json']

resume_content_parser = api.parser()
resume_content_parser.add_argument('content',      type=str, required=True, help='The resume content in the format described by content_type.', location='form')
resume_content_parser.add_argument('content_type', type=str, required=True, help='The resume content type submitted. Currently supported: ' + ', '.join(SUPPORTED_INPUTS), location='form')

resume_content = api.model('ResumeContent', {
  'content'        : fields.String(required=True),
  'content_type'   : fields.String(required=True, enum=SUPPORTED_INPUTS),
})
开发者ID:ipanousis,项目名称:visual-resume-generator,代码行数:32,代码来源:app.py

示例13: Session

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
#######################
app.config['SESSION_TYPE'] = 'filesystem'
session = Session(app)

#############
# blueprint #
#############
blueprint = Blueprint('api', __name__, url_prefix='/api')
api = Api(blueprint, doc='/doc/')

app.register_blueprint(blueprint)

##############
# namespaces #
##############
trans_ns = api.namespace('transmission', description='Operations on transmission API')
auth_ns = api.namespace('authorization', description='Authorization and entitlements API')

##########
# models #
##########
# FIXME: Put models in a centralized map that can be referenced by resources
listed_torrents = api.model('ListedTorrents', {
    'ids': fields.List(fields.Integer, descriptions='An optional list of torrent IDs to retrieve.')
})
auth_model = api.model('AuthModel', {
    'username': fields.String(required=True),
    'password': fields.String(required=True),
    'application': fields.String(required=True),
    'hostname': fields.String(required=False),
    'port': fields.Integer(required=False)
开发者ID:w1sm3rhi11,项目名称:iwatchit,代码行数:33,代码来源:iwatchit.py

示例14: Api

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
import sys
from Project.app import app
from flask.ext.restplus import Api, fields


sys.setrecursionlimit(1000000)

api = Api(app, version='4.0', title='smartlock', description='API for App Controlled Smartlock',
          default="smartlock")
ns = api.namespace('smartlock', description='User operations')

from api_hardware import *
from api_locks import *
from api_users import *
from api_friends import *


@api.doc(responses={200: 'Successfully pinged API'})
class HelloWorld(Resource):
    def get(self):
        """Testing: Primative GET"""
        return {'hello': 'world'}


@api.doc(responses={200: 'Successfully logged in '})
class ProtectedResource(Resource):
    """
    This endpoint is protected by basic auth and is only used for testing
    """
    decorators = [requires_auth]
开发者ID:mingles-,项目名称:SLIP-D,代码行数:32,代码来源:api.py

示例15: swagger_ui

# 需要导入模块: from flask.ext.restplus import Api [as 别名]
# 或者: from flask.ext.restplus.Api import namespace [as 别名]
API_PATH = '/api'


@app.route('/api/', endpoint='api')
def swagger_ui():
    return apidoc.ui_for(api)


@app.route('/')
@app.route('/app')
def hello_world():
    return render_template('criteria.html')


api = Api(app, version='1', title='USSC test task', ui=False)
criteria_ns = api.namespace(name='Criteria', description="Запросы, связанные с критериями", path=API_PATH)
input_box_ip = api.model('BoxIPInput', {'data': fields.String})


@criteria_ns.route('/criteria/<criterion_id>', endpoint='criterion')
class CriterionAPI(Resource):
    def __init__(self):
        super(CriterionAPI, self).__init__()

    def get(self, criterion_id):
        u"""
        Получить критерий
        """
        return {
                "data": {
                        "id": "0b1c7f57-0a89-41bc-966d-474301c25bc9",
开发者ID:ussc-test,项目名称:web-dev,代码行数:33,代码来源:web.py


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