0

I have a problem..

I want to send XLS throught webservices with spyne, but I need, that if this URL

http://127.0.0.1:5000/download/file?A=1

will be pressed, whole XLS will download. Is this possible?

Here is mine code:

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');

Can someone tell me, if I can download whole XLS (I can do anything with that file after URL has been clicked) with Spyne?

Thank You very much, Have a Good Day

1 Answers1

0

So, this is it in 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

You will ask it with:

http://127.0.0.1:5000/download/file?A=1

I hope this will help someone sometimes.. :)