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

205
Views
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
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!