python代码:#postrequest@local_service.route('/serverName/postInterfaceName',methods=['POST'])@cross_origin(supports_credentials=True)defpost_interface_name():##读取json文件返回path=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+'/jsonFile/jsonFileName.json'withopen(path,'r',encoding='utf')asfp:response=json.load(fp)returnresponse#getrequest@local_service.route('/system/time',methods=['GET'])@cross_origin(supports_credentials=True)defget_interface_name():time={"success":True,"code":"8000","result":1625068800000}time_map=json.dumps(time,sort_keys=True,indent=4,separators=(',',':'))returntime_mapif__name__=='__main__':local_service.run(port=8890,debug=True,host='127.0.0.1')charlessetting:接口右键mock--->Mapremote--->选择Protocol,填写HostPortPath--->OK系统每次调用这个接口都会取本地mock数据
