tree: 9fe6bcfcc13698f4c8994bdf7204ed0dc344a714 [path history] [tgz]
  1. README.md
  2. server.py
http/get_simple/python/server/fastapi_uvicorn/README.md

HTTP GET Arrow Data: Simple Python Server Example with FastAPI and Uvicorn

This directory contains a minimal example of an HTTP server implemented in Python using the FastAPI framework and the Uvicorn web server. This example:

  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:

pip install fastapi
pip install "uvicorn[standard]"
pip install pyarrow
uvicorn server:app --port 8008

[!NOTE] This example requires Starlette 0.38.0 or newer, which added support for memoryview in StreamingResponse. If using an older version of Starlette, change both instances of:

with sink.getbuffer() as buffer:
    yield buffer

to:

yield sink.getvalue()