Reputation: 39
I am new to building API's and I'm struggling to use the parameters passed to this GET. The parameters come through as string:key1 and not key1 on its own. How do I get just the value?
app = Flask(__name__)
api = Api(app)
class User_Team_Endpoint(Resource):
def get(self, key1, key2):
data = user_team.get_team()
data = data[0]
data = data.reset_index().to_json(orient='records')
data = json.loads(data)
return data, 200, {'Content-Type':'application/json'}
api.add_resource(User_Team_Endpoint, '/user_team_endpoint/<string:key1><string:key2>')
if __name__ == '__main__':
app.run() # run our Flask app
Upvotes: 0
Views: 510
Reputation: 523
You've missed a Slash on your api.add_resource
api.add_resource(User_Team_Endpoint, '/user_team_endpoint/<string:key1>/<string:key2>')
Upvotes: 1