我正在用flask做一个Web服务,它在Opera gx,IE中工作得很好,但是在chrome和firefox中,不要一次调用该Web服务,该Web服务会发送文件'.xlsx'< / p>
此Web服务用于新的Angular应用,因此我需要返回该Web服务的文件。
def createReport():
script="""
select p.BusinessEntityID,FirstName,LastName, PasswordSalt from person.Person p INNER JOIN
Person.password pa ON p.BusinessEntityID = pa.BusinessEntityID where year(p.ModifiedDate) between '2008' and '2009'
order by firstname asc"""
conn = getConn()
df = pd.read_sql_query(script, conn)
conn.close()
writer = pd.ExcelWriter('report.xlsx')
df.to_excel(writer, sheet_name='Sheet1',index=False)
writer.save()
@webservice.route("/report") def returnfiles():
#this create the report
createReport()
#the line that return the file
return send_file('report.xlsx', as_attachment=True)
现在,当chrome或firefox调用Web服务时,其刚度仅返回文件1次,但是当我更改报表或名称的查询时,它们不会再次调用Web服务。