不论POST请求还是GET请求都支持在 URL 中添加变量,可以选择性的加上一个转换器,为变量指定数据类型。
@history_alarm.route('/test/<int:post_id>', methods=['POST'])
def test(post_id):print(f"参数类型为:{type(post_id)}")in_json = request.get_json()return f'Post {post_id}'
@history_alarm.route('/test/<int:post_id>', methods=['GET'])
def test(post_id):print(f"参数类型为:{type(post_id)}")return f'Post {post_id}'
转换器: