如何在Flask-Restful API中使用参数



我是构建API的新手,我正在努力使用传递给这个GET的参数。参数以字符串key1的形式出现,而不是key1本身。我怎么得到这个值呢?

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

您的api.add_resource

缺少斜杠
api.add_resource(User_Team_Endpoint, '/user_team_endpoint/<string:key1>/<string:key2>')

相关内容

  • 没有找到相关文章

最新更新