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

199
Vistas
How to post image binary to flask rest in javascript

Context

I created a python flask restful service to interact with my MySQL database. I just added a new path to get images and to save it. It works when I tested it with python requests library but I have no idea how to implement this into html and AJAX javascript.

What I Tried

  • I tried to simply google my question in different ways of phrasing it and whatnot but I couldn't find anything useful

What i'm expecting at the end

I simply want to be able to send an image from html webpage to my flask server and have It save the file.


Code

Python code

class process_image(Resource):
    def post(self):
        file = request.files['image']

        file.save('thephotisdfhghdfghfgh.jpg')

        return(200)
api.add_resource(process_image, '/image')


if __name__ == '__main__':
    app.run(debug=True)

Request command

url = 'http://127.0.0.1:5000/image'
my_img = {'image': open('test.jpg', 'rb')}
r = requests.post(url, files=my_img)
about 4 years ago · Santiago Gelvez
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