Send XLS with Spyne
<p>I have a problem.. </p>

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

<pre><code>http://127.0.0.1:5000/download/file?A=1
</code></pre>

<p>will be pressed, whole XLS will download. Is this possible?</p>

<p>Here is mine code:</p>

<pre><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');
</code></pre>

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

<p>Thank You very much,
Have a Good Day</p>

<p>So, this is it in Flask</p>

<pre><code>@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
</code></pre>

<p>You will ask it with:</p>

<pre><code>http://127.0.0.1:5000/download/file?A=1
</code></pre>

<p>I hope this will help someone sometimes.. :)</p>

python excel web-services spyne