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

349
Views
Heroku App, Created File with Python, how can I get the download url?

with my Flask App I created some files to the heroku filesystem. I know that the files are deleted by each dyno restart.

In my html/javascript frontend I want to download it now via button.

The question is, how can I get the download url of these files in the heroku filesystem?

Thank you!

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

I got the solution for my problem:

Python:

@app.route("/test", methods=['GET', 'POST'])
def test():
if request.method == "POST":
    print("hello1")

    f = open("myfile.txt", "w")
    f.write("content")
    f.close()

    f = open("myfile.txt", 'r')

return json.dumps({'success': True, 'data': f.read()}), 200, {'ContentType': 
'application/json'}

Javascript:

$.ajax('/test', {
type: 'POST',
data: { myData: product},
dataType: 'json',
success: function(data, status, xhr) {
    console.log('response')

    console.log(data)

    console.log(data['success'])

    var bytes = new Uint8Array(data['data']); // pass your byte response to this constructor

    var blob=new Blob([data['data']], {type: "text/plain"});// change resultByte to bytes
      
    var link=document.createElement('a');
    link.href=window.URL.createObjectURL(blob);
    link.download="myfile.txt";
    link.click();

    },
    error: function (jqXhr, testStatus, errorMessage) {
        console.log("error")
    }
});
about 4 years ago · Santiago Gelvez Report
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!