Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions http/get_simple/python/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
32 changes: 32 additions & 0 deletions http/get_simple/python/client/urllib.request/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!---
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# 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
```
14 changes: 2 additions & 12 deletions http/get_simple/python/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
35 changes: 35 additions & 0 deletions http/get_simple/python/server/http.server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!---
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# 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.