diff --git a/http/get_simple/python/client/README.md b/http/get_simple/python/client/README.md index d794968..f7c852a 100644 --- a/http/get_simple/python/client/README.md +++ b/http/get_simple/python/client/README.md @@ -17,16 +17,9 @@ under the License. --> -# HTTP GET Arrow Data: Simple Python Client Example +# HTTP GET Arrow Data: Simple Python Client Examples -This directory contains a minimal example of an HTTP client implemented in Python. The client: +This directory contains minimal examples of HTTP clients implemented in Python using various libraries. Each of these clients: 1. Sends an HTTP GET request to a server. 2. Receives an HTTP 200 response from the server, with the response body containing an Arrow IPC stream of record batches. 3. Adds the record batches to a list as they are received. - -To run this example, first start one of the server examples in the parent directory, then: - -```sh -pip install pyarrow -python client.py -``` diff --git a/http/get_simple/python/client/urllib.request/README.md b/http/get_simple/python/client/urllib.request/README.md new file mode 100644 index 0000000..f43884f --- /dev/null +++ b/http/get_simple/python/client/urllib.request/README.md @@ -0,0 +1,32 @@ + + +# HTTP GET Arrow Data: Simple Python Client Example with `urllib.request` + +This directory contains a minimal example of an HTTP client implemented in Python using the built-in [`urllib.request`](https://docs.python.org/3/library/urllib.request.html) module. The client: +1. Sends an HTTP GET request to a server. +2. Receives an HTTP 200 response from the server, with the response body containing an Arrow IPC stream of record batches. +3. Adds the record batches to a list as they are received. + +To run this example, first start one of the server examples in the parent directory, then: + +```sh +pip install pyarrow +python client.py +``` diff --git a/http/get_simple/python/client/client.py b/http/get_simple/python/client/urllib.request/client.py similarity index 100% rename from http/get_simple/python/client/client.py rename to http/get_simple/python/client/urllib.request/client.py diff --git a/http/get_simple/python/server/README.md b/http/get_simple/python/server/README.md index c0b48b0..5de7c20 100644 --- a/http/get_simple/python/server/README.md +++ b/http/get_simple/python/server/README.md @@ -17,19 +17,9 @@ under the License. --> -# HTTP GET Arrow Data: Simple Python Server Example +# HTTP GET Arrow Data: Simple Python Server Examples -This directory contains a minimal example of an HTTP server implemented in Python. The server: +This directory contains minimal examples of HTTP servers implemented in Python using various libraries. Each of these servers: 1. Creates a list of record batches and populates it with synthesized data. 2. Listens for HTTP GET requests from clients. 3. Upon receiving a request, sends an HTTP 200 response with the body containing an Arrow IPC stream of record batches. - -To run this example: - -```sh -pip install pyarrow -python server.py -``` - -> [!NOTE] -> This example uses Python's built-in [`http.server`](https://docs.python.org/3/library/http.server.html) module. This allows us to implement [chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding) manually. Other servers may implement chunked transfer encoding automatically at the cost of an undesirable new layer of buffering. Arrow IPC streams already offer a natural way of chunking large amounts of tabular data. It's not a general requirement, but in this example each chunk corresponds to one Arrow record batch. diff --git a/http/get_simple/python/server/http.server/README.md b/http/get_simple/python/server/http.server/README.md new file mode 100644 index 0000000..1d923ae --- /dev/null +++ b/http/get_simple/python/server/http.server/README.md @@ -0,0 +1,35 @@ + + +# HTTP GET Arrow Data: Simple Python Server Example with `http.server` + +This directory contains a minimal example of an HTTP server implemented in Python using the built-in [`http.server`](https://docs.python.org/3/library/http.server.html) module. The server: +1. Creates a list of record batches and populates it with synthesized data. +2. Listens for HTTP GET requests from clients. +3. Upon receiving a request, sends an HTTP 200 response with the body containing an Arrow IPC stream of record batches. + +To run this example: + +```sh +pip install pyarrow +python server.py +``` + +> [!NOTE] +> This example implements [chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding) manually. Other servers may implement chunked transfer encoding automatically at the cost of an undesirable new layer of buffering. Arrow IPC streams already offer a natural way of chunking large amounts of tabular data. It's not a general requirement, but in this example each chunk corresponds to one Arrow record batch. diff --git a/http/get_simple/python/server/server.py b/http/get_simple/python/server/http.server/server.py similarity index 100% rename from http/get_simple/python/server/server.py rename to http/get_simple/python/server/http.server/server.py