Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

355
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda