0

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

1 Answer 1

1

You've missed a Slash on your api.add_resource

api.add_resource(User_Team_Endpoint, '/user_team_endpoint/<string:key1>/<string:key2>')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.