本文整理汇总了Python中flask_restplus.Namespace.parser方法的典型用法代码示例。如果您正苦于以下问题:Python Namespace.parser方法的具体用法?Python Namespace.parser怎么用?Python Namespace.parser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_restplus.Namespace
的用法示例。
在下文中一共展示了Namespace.parser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import parser [as 别名]
from flask_restplus import Namespace, Resource, fields
from pyris.api import extract
api = Namespace('insee', description='Some stats from INSEE for each IRIS')
population_parser = api.parser()
population_parser.add_argument("by", required=True, location='args',
help="By sex or age")
logement_parser = api.parser()
logement_parser.add_argument("by", required=True, location='args',
help="By room, area or year")
activite_parser = api.parser()
activite_parser.add_argument("by", required=True, location='args',
help="By sex, age")
@api.route('/')
class InseeData(Resource):
@api.doc(description='INSEE data list')
def get(self):
return ['population', 'activite', 'logement',
'menage', 'formation']
@api.route('/population/<string:code>')
class IrisPopulation(Resource):
@api.doc("get the population for an IRIS")
def get(self, code):
if len(code) != 9:
示例2: test_parser
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import parser [as 别名]
def test_parser(self):
api = Namespace('test')
assert isinstance(api.parser(), restplus.reqparse.RequestParser)
示例3: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import parser [as 别名]
logger = logging.getLogger("whiskey-routes")
whiskeyApi = Namespace('whiskey', description='Whiskey related operations')
whiskey = whiskeyApi.model('Whiskey', {
'name': fields.String(required=True, description='The name of the whiskey'),
'proof': fields.Float(required=True, description='The proof of the whiskey'),
'price': fields.Float(required=True, description='The price of the whiskey'),
'style': fields.String(required=True, description='The style of whiskey'),
'age': fields.Integer(required=True, description='The age of the whiskey'),
'icon': fields.Url(required=False, absolute=True, description='The url for the whiskey icon'),
'url': fields.Url(required=False, absolute=True, description='The original url for the whiskey icon')
})
dbm = datastore.DbManager(testMode=False)
getAllParser = whiskeyApi.parser()
getAllParser.add_argument('currentPage', type=int, required=True, default=1, help='Current page of the query, count starts at 1')
getAllParser.add_argument('itemsPerPage', type=int, required=True, default=20, help='Number of items returned per page, max=100')
getAllParser.add_argument('sortField', type=str, required=False, default='name', help='The name of the field to sort on: name, price, proof, style, or age')
getAllParser.add_argument('namesOnly', type=boolean, required=False, default=False, help='Return just a list of Whiskey names')
getParser = whiskeyApi.parser()
getParser.add_argument('name', type=str, required=True, help='The name of the whiskey')
postParser = whiskeyApi.parser()
postParser.add_argument('name', type=str, required=True, help='The name of the whiskey')
postParser.add_argument('proof', type=float, required=False, help='The proof of the whiskey')
postParser.add_argument('price', type=float, required=False, help='The price of the whiskey')
postParser.add_argument('style', type=str, required=False, help='The style of the whiskey')
postParser.add_argument('age', type=int, required=False, help='The age of the whiskey')
postParser.add_argument('icon', type=str, required=False, help='The url for the whiskey icon')
示例4: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import parser [as 别名]
from flask import abort, request
from flask_restplus import Namespace, Resource
from models.database import db
from models.models import POI, Tag
from models.forms import POIForm, POIGeneratorForm
import json
from sqlalchemy.exc import IntegrityError
from dataprocessing.resource_finder import get_points_of_interest
api = Namespace('poi', description="POI Routes")
poi_parser = api.parser()
poi_parser.add_argument('name', type=str, help='name', location='form', required=True)
poi_parser.add_argument('latitude', type=float, help='latitude', location='form', required=True)
poi_parser.add_argument('longitude', type=float, help='longitude', location='form', required=True)
poi_parser.add_argument('tags', type=str, help='json string [{"name":"tag1"},{"name":"tag2"}]', location='form')
poi_parser.add_argument('description', type=str, help='Description', location='form')
poi_generator_parser = api.parser()
poi_generator_parser.add_argument('latitude', type=float, help='latitude', location='form', required=True)
poi_generator_parser.add_argument('longitude', type=float, help='longitude', location='form', required=True)
poi_generator_parser.add_argument('radius', type=float, help='radius', location='form', required=True)
@api.route('/')
class POICrud(Resource):
@api.expect(poi_parser, csrf_enabled=False)
@api.doc(responses={403: 'Form Invalid',404: 'Database Error'})
def post(self):
'Posts a POI for client input'
if request.form.getlist('latitude')!=[]:
form = POIForm(request.form)
示例5:
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import parser [as 别名]
'sour': fields.Float(required=False, description='Sourness of the whiskey'),
'heat': fields.Float(required=False, description='Hotness of the whiskey'),
'smooth': fields.Float(required=False, description='Smoothness of the whiskey'),
'finish': fields.Float(required=False, description='Finish of the whiskey'),
'crisp': fields.Float(required=False, description='Crispness of the whiskey'),
'leather': fields.Float(required=False, description='Leatheriness of the whiskey'),
'wood': fields.Float(required=False, description='Woodiness of the whiskey'),
'smoke': fields.Float(required=False, description='Smokeyness of the whiskey'),
'citrus': fields.Float(required=False, description='Citrusness of the whiskey'),
'floral': fields.Float(required=False, description='Floralness of the whiskey'),
'fruit': fields.Float(required=False, description='Fruitiness of the whiskey'),
})
dbm = datastore.DbManager(testMode=False)
getAllParser = ratingApi.parser()
getAllParser.add_argument('currentPage', type=int, required=True, default=1, help='Current page of the query, count starts at 1')
getAllParser.add_argument('itemsPerPage', type=int, required=True, default=20, help='Number of items returned per page, max=100')
getAllParser.add_argument('sortField', type=str, required=False, default='whiskeyId', help='The name of the field to sort on: userId, whiskeyId, rating, wood, smoke, etc')
getParser = ratingApi.parser()
getParser.add_argument('whiskeyId', type=int, required=True, help='The ID of the whiskey')
getParser.add_argument('userId', type=int, required=True, help='The ID of the user')
ppParser = ratingApi.parser()
ppParser.add_argument('whiskeyId', type=int, required=True, help='The ID of the whiskey')
ppParser.add_argument('userId', type=int, required=True, help='The ID of the user')
ppParser.add_argument('rating', type=float, required=False, help='User rating of the whiskey')
ppParser.add_argument('notes', type=str, required=False, help='User note about the whiskey')
ppParser.add_argument('sweet', type=float, required=False, help='Sweetness of the whiskey')
ppParser.add_argument('sour', type=float, required=False, help='Sourness of the whiskey')
示例6:
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import parser [as 别名]
attribute='spread',
description='Context'),
'status': fields.Constant(
ctype='AccountHomeStatus',
description='Home status'),
'disk_id': fields.base.Integer(
description='Disk entity ID'),
})
AccountHomeList = api.model('AccountHomeList', {
'homes': fields.base.List(
fields.base.Nested(AccountHome),
description='Home directories'),
})
password_parser = api.parser()
password_parser.add_argument(
'password',
type=validator.String(),
required=True,
location='form',
help='Password',
)
PasswordChanged = api.model('PasswordChanged', {
'password': fields.base.String(
description='New password')
})
PasswordVerification = api.model('PasswordVerification', {
'verified': fields.base.Boolean(