![]() |
Process the image on the Python HTTP server - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Process the image on the Python HTTP server (/thread-35693.html) |
Process the image on the Python HTTP server - Aleks - Dec-02-2021 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() |