使用 Spyne 发送 XLS

Send XLS with Spyne

我有问题..

我想用 spyne 通过网络服务发送 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');

有人可以告诉我,如果我可以用 Spyne 下载整个 XLS(我可以在单击 URL 后对该文件执行任何操作)?

非常感谢, 祝你有个美好的一天

所以,这就是 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

我希望这有时能对某人有所帮助..:)