flask rest pass parameter code example
Example 1: flask api with parameter
args = request.args
print (args)
no1 = args['key1']
no2 = args['key2']
return jsonify(dict(data=[no1, no2]))
Example 2: flask restful arguments in url
from flask import Flask, request
from flask_restful import Api, Resource
app = Flask(__name__)
api = Api(app)
TRUTHY = ['true', 'True', 'yes']
class Item(Resource):
def get():
classes = request.args.getlist('class')
analysis = True if request.args.get('analysis') in TRUTHY else False
api.add_resource(Item, '/item')