本文整理汇总了Python中flask_restful.fields.String方法的典型用法代码示例。如果您正苦于以下问题:Python fields.String方法的具体用法?Python fields.String怎么用?Python fields.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_restful.fields
的用法示例。
在下文中一共展示了fields.String方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def __init__(self, **kwargs):
self.restapi = kwargs['restapi']
self.server = kwargs['server']
self.fields = {
'host': fields.String,
'eui': fields.Integer,
'name': fields.String,
'enabled': fields.Boolean,
'power': fields.Integer,
'created': fields.DateTime(dt_format='iso8601'),
'updated': fields.DateTime(dt_format='iso8601')
}
self.parser = reqparse.RequestParser(bundle_errors=True)
self.parser.add_argument('host', type=str)
self.parser.add_argument('eui', type=int)
self.parser.add_argument('name', type=str)
self.parser.add_argument('enabled', type=inputs.boolean)
self.parser.add_argument('power', type=int)
self.args = self.parser.parse_args()
示例2: __init__
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def __init__(self, **kwargs):
self.restapi = kwargs['restapi']
self.server = kwargs['server']
self.fields = {
'appif': fields.Integer,
'name': fields.String,
}
self.parser = reqparse.RequestParser(bundle_errors=True)
self.parser.add_argument('type', type=str)
self.parser.add_argument('name', type=str)
self.parser.add_argument('file', type=str)
self.parser.add_argument('protocol', type=str)
self.parser.add_argument('iothost', type=str)
self.parser.add_argument('keyname', type=str)
self.parser.add_argument('keyvalue', type=str)
self.parser.add_argument('pollinterval', type=int)
self.args = self.parser.parse_args()
示例3: get
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def get(self):
"""Method to get all application interfaces"""
try:
interfaces = interfaceManager.getAllInterfaces()
if interfaces is None:
returnValue({})
marshal_fields = {
'type': fields.String(attribute='__class__.__name__'),
'id': fields.Integer(attribute='appinterface.id'),
'name': fields.String
}
data = {}
for i,interface in enumerate(interfaces):
data[i] = marshal(interface, marshal_fields)
returnValue(data)
yield
except TimeoutError:
log.error("REST API timeout retrieving application interfaces")
示例4: marshal
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def marshal(self):
"""Get REST API marshalled fields as an orderedDict
Returns:
OrderedDict of fields defined by marshal_fields
"""
marshal_fields = {
'type': fields.String(attribute='__class__.__name__'),
'id': fields.Integer(attribute='appinterface.id'),
'name': fields.String,
'iothost': fields.String,
'keyname': fields.String,
'keyvalue': fields.String,
'started': fields.Boolean,
}
return marshal(self, marshal_fields)
示例5: marshal
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def marshal(self):
"""Get REST API marshalled fields as an orderedDict
Returns:
OrderedDict of fields defined by marshal_fields
"""
marshal_fields = {
'type': fields.String(attribute='__class__.__name__'),
'id': fields.Integer(attribute='appinterface.id'),
'name': fields.String,
'iothost': fields.String,
'keyname': fields.String,
'keyvalue': fields.String,
'poll_interval': fields.Integer,
'started': fields.Boolean,
}
return marshal(self, marshal_fields)
示例6: response_fields
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def response_fields(cls):
fields = super(Plugin, cls).response_fields
fields['file_server_path'] = flask_fields.String
fields['yaml_url_path'] = flask_fields.String
return fields
示例7: __init__
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def __init__(self, **kwargs):
self.restapi = kwargs['restapi']
self.server = kwargs['server']
self.fields = {
'name': fields.String,
'listen': fields.String,
'port': fields.Integer,
'webport': fields.Integer,
'apitoken': fields.String,
'freqband': fields.String,
'netid': fields.Integer,
'duplicateperiod': fields.Integer,
'fcrelaxed': fields.Boolean,
'otaastart': fields.Integer,
'otaaend': fields.Integer,
'macqueueing': fields.Boolean,
'macqueuelimit': fields.Integer,
'adrenable': fields.Boolean,
'adrmargin': fields.Float,
'adrcycletime': fields.Integer,
'adrmessagetime': fields.Integer,
}
self.parser = reqparse.RequestParser(bundle_errors=True)
self.parser.add_argument('name', type=str)
self.parser.add_argument('listen', type=str)
self.parser.add_argument('port', type=int)
self.parser.add_argument('webport', type=int)
self.parser.add_argument('apitoken', type=str)
self.parser.add_argument('freqband', type=str)
self.parser.add_argument('netid', type=int)
self.parser.add_argument('duplicateperiod', type=int)
self.parser.add_argument('fcrelaxed', type=bool)
self.parser.add_argument('otaastart', type=int)
self.parser.add_argument('otaaend', type=int)
self.parser.add_argument('macqueuing', type=bool)
self.parser.add_argument('macqueuelimit', type=int)
self.parser.add_argument('adrenable', type=bool)
self.parser.add_argument('adrmargin', type=float)
self.parser.add_argument('adrcycletime', type=int)
self.parser.add_argument('adrmessagetime', type=int)
self.args = self.parser.parse_args()
示例8: __init__
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def __init__(self, **kwargs):
self.restapi = kwargs['restapi']
self.server = kwargs['server']
self.fields = {
'deveui': fields.Integer,
'name': fields.String,
'devclass': fields.String,
'enabled': fields.Boolean,
'otaa': fields.Boolean,
'devaddr': fields.Integer,
'appeui': fields.Integer,
'appskey': fields.Integer,
'nwkskey': fields.Integer,
'tx_datr': fields.String,
'snr_average': fields.Float,
'appname': fields.String,
'latitude': fields.Float,
'longitude': fields.Float,
'created': fields.DateTime(dt_format='iso8601'),
'updated': fields.DateTime(dt_format='iso8601')
}
self.parser = reqparse.RequestParser(bundle_errors=True)
self.parser.add_argument('deveui', type=int)
self.parser.add_argument('name', type=str)
self.parser.add_argument('devclass', type=str)
self.parser.add_argument('enabled', type=inputs.boolean)
self.parser.add_argument('otaa', type=inputs.boolean)
self.parser.add_argument('devaddr', type=int)
self.parser.add_argument('appeui', type=int)
self.parser.add_argument('nwkskey', type=int)
self.parser.add_argument('appskey', type=int)
self.parser.add_argument('appname', type=str)
self.parser.add_argument('latitude', type=float)
self.parser.add_argument('longitude', type=float)
self.args = self.parser.parse_args()
示例9: __init__
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def __init__(self, **kwargs):
self.restapi = kwargs['restapi']
self.server = kwargs['server']
self.fields = {
'appeui': fields.Integer,
'name': fields.String,
'domain': fields.String,
'appnonce': fields.Integer,
'appkey': fields.Integer,
'fport': fields.Integer,
'appinterface_id': fields.Integer,
'properties': {},
'created': fields.DateTime(dt_format='iso8601'),
'updated': fields.DateTime(dt_format='iso8601')
}
self.pfields = {
'port': fields.Integer,
'name': fields.String,
'type': fields.String,
'created': fields.DateTime(dt_format='iso8601'),
'updated': fields.DateTime(dt_format='iso8601')
}
self.parser = reqparse.RequestParser(bundle_errors=True)
self.parser.add_argument('appeui', type=int)
self.parser.add_argument('name', type=str)
self.parser.add_argument('domain', type=str)
self.parser.add_argument('appnonce', type=int)
self.parser.add_argument('appkey', type=int)
self.parser.add_argument('fport', type=int)
self.parser.add_argument('interface', type=int)
self.args = self.parser.parse_args()
示例10: marshal
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def marshal(self):
"""Get REST API marshalled fields as an orderedDict
Returns:
OrderedDict of fields defined by marshal_fields
"""
marshal_fields = {
'type': fields.String(attribute='__class__.__name__'),
'id': fields.Integer(attribute='appinterface.id'),
'name': fields.String,
'started': fields.Boolean
}
return marshal(self, marshal_fields)
示例11: marshal
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def marshal(self):
"""Get REST API marshalled fields as an orderedDict
Returns:
OrderedDict of fields defined by marshal_fields
"""
marshal_fields = {
'type': fields.String(attribute='__class__.__name__'),
'id': fields.Integer(attribute='appinterface.id'),
'name': fields.String,
'file': fields.String,
'started': fields.Boolean
}
return marshal(self, marshal_fields)
示例12: listen_to_web
# 需要导入模块: from flask_restful import fields [as 别名]
# 或者: from flask_restful.fields import String [as 别名]
def listen_to_web(args, max_positions, task, process_batch):
# initialize web app
app = Flask(__name__, static_folder='')
api = Api(app)
# register route for web server
# a simple form page
@app.route('/form')
def form():
input = request.args.get('input', '')
inputs = [input]
results, outputs = process_inputs(args, inputs, max_positions, task, process_batch)
return render_template('form.html', input=input, outputs=outputs)
# a dynamic web app with static resource
@app.route('/')
def index():
return render_template('index.html')
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('templates/static', path)
# a JSON api
resource_fields = {
'iteration': fields.Integer,
'src_str': fields.String, 'hypo_str': fields.String,
'hypo_score': fields.Float, 'pos_scores': fields.Float, 'gleu_scores': fields.Float,
'fluency_scores': fields.Float, 'alignments': fields.Float,
'hypo_score_str': fields.String, 'pos_scores_str': fields.String, 'gleu_scores_str': fields.String,
'fluency_scores_str': fields.String, 'alignments_str': fields.String
}
class API(Resource):
@marshal_with(resource_fields)
def get(self, input):
inputs = [input]
results, outputs = process_inputs(args, inputs, max_positions, task, process_batch)
# return outputs # raw string outputs
return results # json
# register routes for API
api.add_resource(API, '/api/<string:input>')
# listen with web server
print('server running at port: {}'.format(args.port))
http_server = WSGIServer(('', args.port), app)
http_server.serve_forever()