I want to create a resource that supports GET request in following way:
/bar?key1=val1&key2=val2
I tried this code, but it is not working
app = Flask(__name__)
api = Api(app)
class BarAPI(Resource):
def get(key1, key2):
return jsonify(dict(data=[key1, key2]))
api.add_resource(BarAPI, '/bar', endpoint='bar')
Thanks!
Flask can parse arguments through request
You can use following lines in the block that requires GET parameters. GET is declared in
@app.route()
declaration.