• Version: 20261019
  • Source Code Copyright: Unknown
  • Redistribution Restriction: This source code is integrated by LEADERG INC. Please use it privately. Please DO NOT distribute it to internet.

Spyder IDE project with one Python client, curl_http_post_image.py, that uploads an image to a web API with PycURL (the Python interface to libcurl). It posts data/image.png as the multipart form field image to http://127.0.0.1:8080/api/inference, then prints the server's reply and the time the request took. This folder holds only the client, not a server, so a web API that answers POST /api/inference on port 8080 must already be running.

 

[Folder Structure]

  • .spyproject/: Spyder project settings (open this folder as a Spyder project).
  • copyright.txt: Copyright notice.
  • curl_http_post_image.py: The client: posts data/image.png to http://127.0.0.1:8080/api/inference with PycURL and prints the reply and the time cost.
  • data/image.png: Image that is posted: a 512x512 brain MRI slice (the file holds JPEG data despite its .png extension; it is sent as raw bytes).
  • Network-CURL-Spyder.html: This document (usage page).

[Prerequisites]

  • Python 3.
  • pip package: pycurl (the only third-party import; the rest is the standard library: io, threading, time, sys).
  • Spyder (optional; the script also runs from a terminal).
  • A server listening on 127.0.0.1:8080 that accepts a multipart POST with an image field at /api/inference.

[How to Run]

  1. Start the web API server that provides http://127.0.0.1:8080/api/inference.
  2. In Spyder, choose Projects > Open Project... and select this folder, open curl_http_post_image.py and run it (F5). The script reads data/image.png relative to the current directory, so the working directory must be the project folder. From a terminal opened in the project folder: pip install pycurl
    • python curl_http_post_image.py
  3. The console shows libcurl's verbose request log, then result = followed by the server's reply, and time cost = ... ms.

Parameters at the top of the script:

  • url — Value: http://127.0.0.1:8080/api/inference; Meaning: Target endpoint.
  • timeOut — Value: 30; Meaning: Connect and total timeout in seconds.
  • num_thread — Value: 1; Meaning: Number of client threads; each thread sends one request, so raise it to send concurrent requests.
  • filename — Value: data/image.png; Meaning: Image to post.

[Notes]

  • The request sets the headers Keep-Alive: 300 and Connection: Keep-Alive, an empty Expect: header (so libcurl does not send Expect: 100-continue) and the user agent Mozilla/5.0.
  • The reply is decoded as UTF-8 text and printed as is; the script does not parse it.

[Version History]

  • 20261019: The folder was renamed from Network-CURL-Spyder-2 to Network-CURL-Spyder-20261019 (the version is now the date of the last change, YYYYMMDD). This usage page was added and the version history moved here from version.txt, which was removed.
  • 2: Add main function and debug.
  • 1: No description recorded.

 

This SDK is built in AppForAI - AI Dev Tools.