Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
How to get file from flask send with AJAX

I'm trying to get flask to send a trial xlsx file with Ajax. My Javascript code is:

$('#download-button').click(function(event) {
    $.ajax({
        data : {'download_map': 'download_map'},
        type : 'POST',
        url : '/download'
    });
});

And the python looks like:

@app.route('/download', methods=['POST'])
def download():
    file = io.BytesIO()
    wb = Workbook(file)
    ws = wb.add_worksheet()
    ws.write('A1','Hello World')
    wb.close()
    file.seek(0)
    wrapped_file = FileWrapper(file)
    print('Gets here')
    return Response(
        wrapped_file,
        mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        direct_passthrough=True
    )

Although this successfully sends a response, it doesn't allow the user to download the file. Is there something I am missing here?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!