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


Python Api.namespace方法代码示例

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


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

示例1: Flask

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
    routes,
    api
)

app = Flask(__name__,
            template_folder='src/view/pages',
            static_folder='src/view/static')

config_module = 'local_config' if os.path.isfile('local_config.py') else 'config'
app.config.from_object(config_module)

restplus_api = Api(app,
                   version='1.0',
                   title='bubup !'
                   )
ns = restplus_api.namespace(name='api', description='WOW bubup !')
mongo_instance = Database(app)

api.initialize(ns, restplus_api, mongo_instance)
routes.initialize(app, mongo_instance)

if __name__ == '__main__':
    # for x in app.url_map.iter_rules():
    #     print x

    app.run(threaded=True,
            debug=True,
            use_reloader=False,
            host='192.168.56.101',
            port=5001)
开发者ID:joe-doe,项目名称:bubble-up-priorities,代码行数:32,代码来源:bubup.py

示例2: Api

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

### API Controllers ###

# And create the flask-restplus API
api = Api(module_one, doc='/doc/',
    version='1.0', title='Module One API',
    description="""\
This is the API for Module One. It does the following:

* Records greetings for users given by user name
* Looks up the greeting for a user given by user name
""")

# This is the route namespace for the API
ns = api.namespace("api", description="Module One API")

# Describe the model used by the API
m1 = api.model("Module One", {
    "user_name": fields.String(required=True, description="The name of the user"),
    "greeting": fields.String(description="A specific greeting for a user"),
})

# the data store :)
class UserGreetings(dict):
    def validate(self, data):
        if "user_name" not in data:
            abort(400, "Invalid request")
user_greetings = UserGreetings()

开发者ID:ryanroser,项目名称:barnacle,代码行数:30,代码来源:controllers.py

示例3: Blueprint

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
import  os, random, exceptions
from flask import render_template, flash, redirect, session, url_for, request, jsonify, json, Blueprint, render_template, abort
from jinja2 import TemplateNotFound
from app import app
from models import Game, Ship, Faction, Body, Star
from flask_restplus import Api, Resource, fields, apidoc

ajax = Blueprint('ajax', __name__,
                        template_folder='templates')

api = Api(app, version='1.0', title='Todo API',
    description='A simple TODO API extracted from the original flask-restful example',
)

ns = api.namespace('ajax', description='Kvantgen API 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')
开发者ID:avalikarvamus,项目名称:kvantgen,代码行数:32,代码来源:ajax.py

示例4: Flask

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

VERSION = '0.1.0'

app = Flask(__name__)
api = Api(app, version=VERSION, title='Fibonacci Sequence API',
          description='An API that returns the first n integers of the Fibonacci Sequence.',
          validate=True
          )

ns = api.namespace('fibonacci', description='fibonacci operation')


@ns.route('/<path:input>')
@api.response(200, 'Success - sequence returned')
@api.response(400, 'Invalid Input')
@api.doc(params={'input': 'The count of Fibonacci sequence numbers to return.'})
class Fibonappi(Resource):
    '''Get the desired count of numbers in the Fibonacci sequence.'''

    def abort_if_non_int(self, input):
        try:
            return int(input)
        except ValueError:
            api.abort(400, 'Invalid input {}. Integer required.'.format(input))

    def abort_on_negative(self, number):
        if number < 0:
            api.abort(400, "The number {} does not work for the Fibonacci sequence.".format(number))
开发者ID:jessegonzalez,项目名称:fibonappi,代码行数:32,代码来源:__init__.py

示例5: Flask

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
#! /usr/bin/env python

# -*- coding: utf-8 -*-

from flask import Flask
from flask_restplus import Api, Resource, fields
from subprocess import check_output
import sys
import os
import shutil

app = Flask(__name__)
api = Api(app, version='0.1', title='Speak API',
          description='Get phonemes of a text from various TTS backends')

ns = api.namespace('speaks', descripton='Speak operations')

Backends = {
    'espeak': {
        'binary': '',
        'info': 'http://espeak.sourceforge.net/',
        'availability': ['darwin', 'linux', 'win32', 'cygwin'],
        'parameters': [
            {'name': 'text', 'arg': ' ', 'type': 0, 'required': True},
            {'name': 'phoneme', 'arg': '-x'},
            {'name': 'quiet', 'arg': '-q'},
        ],
    },
    'flite': {
        'binary': '',
        'info': 'http://www.festvox.org/flite/',
开发者ID:EsOff,项目名称:RESTfulSpeak,代码行数:33,代码来源:api.py

示例6: get_stop_words

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
        summarizer.stop_words = get_stop_words(self.LANGUAGE)
        summary = " ".join([obj._text for obj in summarizer(parser.document, length)])

        return summary


app = Flask(__name__)


api = Api(app, version='1.0', title='Summary API',
    description='A simple review summarization API which uses Python\'s sumy library'
)

app.config.SWAGGER_UI_DOC_EXPANSION = 'list'

ns = api.namespace('sum/v1.0', 'Text Summary v1.0 ')

parser = api.parser()
parser.add_argument('reviews', required=True, location='json', help='Input Format -> {"reviews":[ {"reviewer_id":"string","reviewee_id":"string","score":"string","feedback":"string"}]}')

parser_sum = api.parser()
parser_sum.add_argument('sentences', required=True, location='json', help='Input Format -> {"sentences":["sentence1"]')


###### Definition of data model for documentation
summary_marshaller = api.model('summary_marshaller',{
    'summary': fields.String(description='Summary of the review')
})

message_marshaller = api.model('message_marshaller',{
    'message': fields.String(description='Api call status', required=True)
开发者ID:peerlogic,项目名称:AutoSummaryV1,代码行数:33,代码来源:AutoSummary.py

示例7: Flask

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

app = Flask(__name__)

api = Api(
    app,
    version="1.0",
    title="Summary API",
    description="A simple review summarization API which uses Python's sumy library",
)

CORS(app)

app.config.SWAGGER_UI_DOC_EXPANSION = "list"

ns = api.namespace("sum/v1.0", "Text Summary v1.0 ")

parser = api.parser()
parser.add_argument(
    "reviews",
    required=True,
    location="json",
    help="Input Format : "
    "<br>{"
    '<br>&nbsp;"reviews":[{'
    '<br>&nbsp;&nbsp;&nbsp;&nbsp;"reviewer_id":"string",'
    '<br>&nbsp;&nbsp;&nbsp;&nbsp;"reviewee_id":"string",'
    '<br>&nbsp;&nbsp;&nbsp;&nbsp;"score":"string",'
    '<br>&nbsp;&nbsp;&nbsp;&nbsp;"feedback":"string"'
    "<br>&nbsp;&nbsp;}]"
    "<br>}",
开发者ID:ferryxo,项目名称:AutoSummaryV1,代码行数:32,代码来源:AutoSummary.py

示例8: Flask

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
from flask import Flask, json, jsonify, render_template, request
from bson import json_util
from datetime import datetime
from urlparse import urlparse, parse_qs
from pymongo import MongoClient

from flask_restplus import Api, Resource, fields, swagger

app = Flask(__name__)
api = Api(app, version="1.0", title="My API", description="Flask-RestPlus 사용해보자")

client = MongoClient("mongodb://t.com:27017")
db = client.mydb

ns = api.namespace("Member", description="MemberAPI")


@ns.route("/<string:name>")
@api.doc(params={"name": "member name"})
class Member(Resource):
    @app.route("/Member/<name>", methods=["POST"])
    def post(name):
        data = {"age": 30, "name": name, "cdate": datetime.now()}
        db.member.insert(data)
        return name

    @app.route("/Member/<name>")
    def get(name):
        data = json_util.dumps(db.member.find({"name": name}))
        return render_template("user.html", users=json.loads(data))
开发者ID:lhr0916,项目名称:flask_restplus_my_app,代码行数:32,代码来源:restplus.py

示例9: Flask

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
from flask import Flask, request, send_file,  jsonify
from flask_restplus import Resource, Api
from werkzeug.datastructures import FileStorage
from threading import Thread

from settings import BaseConfig
from job_model import JobStatus, Job, JobSchema

# Extensions initialization
# =========================
app = Flask(__name__)
api = Api(app, version='1.0', title='Name classificator study API',
    description='This service using for training name classification model',
)

ns = api.namespace('new-jobs', description='Jobs for ML models study')

upload_parser = api.parser()
upload_parser.add_argument('file', location=BaseConfig.UPLOAD_DIR,
                           type=FileStorage, required=True)

# Data layer - Collections
# ========================
jobs = []

# Routes
# ======
@ns.route('/')
class JobList(Resource):
    # Shows a list of all jobs, and lets you POST to add new jobs
    def get(self):
开发者ID:Rosdex,项目名称:rest-category-classificator-study,代码行数:33,代码来源:run.py

示例10: Api

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
from flask_restplus import Api, Resource, fields, reqparse
import summarize
import textrank
import datetime
from app import app


description = """ An API to generate summaries of submitted text """

api = Api(app, version='1.0', title='Summarizer API',
          description=description,)

# URLs for this namespace are prefixed with /api/
ns = api.namespace('api', description='Summary Generation operations')


# Defines a model for Summaries
# based on the dataframe already generate by Crawler
summary = api.model('Summary', {
    'article_summary': fields.String,
    'algorithm': fields.String,
    'utc_date_generated': fields.DateTime()})


@ns.route('/summarize')
class Summary(Resource):
    """
    Returns a summary from entered text :
        article_summary: Shortened text
        algorithm: algorithm used
        utc_date_generated: Timezone aware timestamp (UTC)
开发者ID:dezoito,项目名称:flask_Summarizer,代码行数:33,代码来源:api.py

示例11: Api

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
# -*- coding: utf-8 -*-

from application import app
from flask import render_template
from application.models import *
from flask_restplus import Api, Resource, fields
from flask.ext.restplus.reqparse import RequestParser
from flask.ext.restplus.inputs import date
import application.script_creator2 as sc
import json
import random

api = Api(app, version='1.0', title=u'Mobiliário Urbano API', doc='/api')
ns = api.namespace('MobUrb', description=u'Mobiliário Urbano Operations')

video_parser = RequestParser()
video_parser.add_argument('video_id', type=int)

video_fields = {'id': fields.Integer(),
                'name': fields.String(),
                'duration': fields.Float(),
                'high_def': fields.String(),
                'standard_def_big': fields.String(),
                'standard_def_small': fields.String(),
                }

video_model = api.model('Video', video_fields)

@app.route('/roteiro')
@app.route('/roteiro/<slug>')
def roteiro(slug=None):
开发者ID:Agreste,项目名称:MobUrbRoteiro,代码行数:33,代码来源:manager.py

示例12: Blueprint

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
# -*- coding: utf-8 -*-
from flask import Blueprint
from flask_restplus import Api

app = Blueprint('api', __name__)
api = Api(app, version='1.0', title='GST API', description='GST API for Game Manager', catch_all_404s=True)

ns_users = api.namespace('users')
ns_posts = api.namespace('posts')
开发者ID:amorwilliams,项目名称:gst,代码行数:11,代码来源:views.py

示例13: Api

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
from application import app
from flask import render_template
from application.models import *
from flask_restplus import Api, Resource, fields
from flask.ext.restplus.reqparse import RequestParser
from flask.ext.restplus.inputs import date

api = Api(app, version='1.0', title='ElesVotam API')
ns = api.namespace('elesvotam', description='ElesVotam operations')

votacao_parser = RequestParser()
votacao_parser.add_argument('votacaoid', type=int)

votacao_fields = {'votacaoid': fields.Integer(),
                  'sessao_id': fields.Integer(),
                  'tipo': fields.String(),
                  'materia': fields.String(),
                  'ementa': fields.String(),
                  'resultado': fields.String(),
                  'presentes': fields.String(),
                  'sim': fields.Integer(),
                  'nao': fields.Integer(),
                  'abstencao': fields.Integer(),
                  'branco': fields.Integer(),
                  'notas_rodape': fields.String(),
                  }

votacao_model = api.model('Votacao', votacao_fields)

@ns.route('/votacao')
class ElesVotamVotacaosApi(Resource):
开发者ID:okfn-brasil,项目名称:elesvotam,代码行数:33,代码来源:manager.py

示例14: Blueprint

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
# -*- coding: utf-8 -*-
from flask_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,
                   users, customer)
    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:Hoedic,项目名称:APITaxi,代码行数:26,代码来源:__init__.py

示例15: Flask

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import namespace [as 别名]
from flask import Flask, request, jsonify, make_response
from flask_restplus import Api, Resource, fields
from sklearn.externals import joblib

flask_app = Flask(__name__)
app = Api(app = flask_app, 
		  version = "1.0", 
		  title = "ML React App", 
		  description = "Predict results using a trained model")

name_space = app.namespace('prediction', description='Prediction APIs')

model = app.model('Prediction params', 
				  {'textField1': fields.String(required = True, 
				  							   description="Text Field 1", 
    					  				 	   help="Text Field 1 cannot be blank"),
				  'textField2': fields.String(required = True, 
				  							   description="Text Field 2", 
    					  				 	   help="Text Field 2 cannot be blank"),
				  'select1': fields.Integer(required = True, 
				  							description="Select 1", 
    					  				 	help="Select 1 cannot be blank"),
				  'select2': fields.Integer(required = True, 
				  							description="Select 2", 
    					  				 	help="Select 2 cannot be blank"),
				  'select3': fields.Integer(required = True, 
				  							description="Select 3", 
    					  				 	help="Select 3 cannot be blank")})

# classifier = joblib.load('classifier.joblib')
开发者ID:rymndlcnn,项目名称:ML-React-App-Template,代码行数:32,代码来源:app.py


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