Python Forum
Process the image on the Python HTTP server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Process the image on the Python HTTP server
#1
Python 3.9. Local http.server 127.0.0.1:9001. I need to take an image, then save it to disk. The program that sends the image sends it with a POST request with the Multipart/form-data type, the image itself is jpg. At the moment there is such a code:

from http.server import BaseHTTPRequestHandler, HTTPServer

class MyServer(BaseHTTPRequestHandler):
        def _set_headers(self):
            self.send_response(200)
            self.send_header('Content-type', 'application/json')
            self.end_headers()

        def do_POST(self):
            content_length = int(self.headers['Content-Length'])
            post_data = self.rfile.read(content_length)
            self.wfile.write(post_data .encode('utf-8'))
    webServer = HTTPServer(("", 9001), MyServer)
    webServer.serve_forever() 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 383 Jan-26-2024, 07:02 PM
Last Post: deanhystad
  Question about Creating an Automated Process in Python Supratik1234 0 755 Jan-13-2023, 08:29 PM
Last Post: Supratik1234
  Python multiprocessing Pool apply async wait for process to complete sunny9495 6 6,467 Apr-02-2022, 06:31 AM
Last Post: sunny9495
  Upload image to Instagram using python/selenium using image URL failed, need help greenpine 5 5,498 Feb-22-2022, 09:42 PM
Last Post: snippsat
  How to take the tar backup files form remote server to local server sivareddy 0 1,917 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Multithreaded HTTP Server sbguy01 0 6,240 Oct-21-2020, 04:42 PM
Last Post: sbguy01
  PIL Image / python-resize-image AttributeError sallyjc81 1 5,022 Aug-02-2020, 12:06 AM
Last Post: scidam
  How to to tie the execution of one process to another inside a loop in Python ignorant_wanderer 0 2,057 Jul-11-2020, 03:44 AM
Last Post: ignorant_wanderer
  Module : http.server JohnnyCoffee 3 102,369 Jul-07-2020, 04:48 AM
Last Post: ndc85430
  ModuleNotFoundError: No module named 'http.client'; 'http' is not a package abhishek81py 1 15,488 Jun-25-2020, 08:58 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020