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

331
Views
¿Cómo enviar una imagen de FLASK a JavaScript (JSON)?
function classifyWaste(){ var file = document.getElementById("file").files; if(file.length > 0){ var form_data = new FormData(); form_data.append("file", document.getElementById("file").files[0]); $.ajax({ url: 'classifywaste', // point to server-side URL dataType: 'json', // what to expect back from server cache: false, contentType: false, processData: false, data: form_data, type: 'post', success: function (data) { var response = response["response"]; // I want to receive returned file from classifywaste() (app.py) document.getElementById("image_to_replace").setAttribute("src", "SOME_IMAGE_FILE"); } }); }

Encontré una manera de hacerlo codificando con base64 pero no pude implementarlo claramente. Entonces, ¿cómo puedo codificar la imagen en base64 desde el matraz y devolver su cadena, y luego decodificarla desde el archivo javaScript para publicarla en la interfaz?

 @application.route("/classifywaste", methods=["POST"]) def classifywaste(): image_data = request.files["file"] .... // Image received and performed other actions // lets say, I have received image file after classifying image_file_after = util.classify_waste(image_path) // Here, I want to return image file to the classifyWaste() in .js file return jsonify(response=response)

¿Puede establecer el código para base64 para este caso? ¡Gracias!

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!