Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

365
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda