Ejemplo 1: api de matraz con parámetro
args = request.args
print (args) # For debugging
no1 = args['key1']
no2 = args['key2']
return jsonify(dict(data=[no1, no2])) # or whatever is required
Ejemplo 2: matraz de argumentos tranquilos en url
from flask import Flask, request
from flask_restful import Api, Resource
app = Flask(__name__)
api = Api(app)
# Flask mishandles boolean as string
TRUTHY = ['true', 'True', 'yes']
class Item(Resource):
def get():
# Get `class` list from request args
classes = request.args.getlist('class')
# Get `analysis` boolean from request args
analysis = True if request.args.get('analysis') in TRUTHY else False
api.add_resource(Item, '/item')
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)