我有个问题..
我想通过spyne的URL服务发送XLS,但我需要的是,如果此URL
http://127.0.0.1:5000/download/file?A=1将被按下,整个XLS将被下载。这个是可能的吗?
下面是我的代码:
class xlsDownload(spyne.Service):
__service_url_path__ = '/download';
__in_protocol__ = HttpRpc(validator='soft');
__out_protocol__ = MessagePackDocument()#HtmlRowTable()#MessagePackRpc()
@spyne.srpc(Unicode, _returns=File)
def Function(A):
GetXLS(A)
return File.Value(data=open("File.xls", 'rb', type='application/vnd.ms-excel');谁能告诉我,如果我可以下载整个XLS ( URL被点击后,我可以对该文件做任何事情)与Spyne?
非常感谢,祝您有愉快的一天
发布于 2016-09-13 03:06:33
所以,这就是Flask中的
@app.route("/download/file")
def xlsDownload(A):
GetXLS(A)
response = Response(bytearray(open("file.xls", "rb").read()))
response.headers["Content-Type"] = "application/vnd.ms-excel"
response.headers["Content-Disposition"] = "attachment; filename = file.xls"
return response你可以这样问:
http://127.0.0.1:5000/download/file?A=1我希望这对某些人有帮助..:)
https://stackoverflow.com/questions/39416001
复制相似问题