Skip to content

Commit

Permalink
Try with requests
Browse files Browse the repository at this point in the history
Direct read of the request object does not work,
beause it does not implement seek() - which we currently rely on
  • Loading branch information
jonnor committed Aug 11, 2024
1 parent ba2e4a8 commit 7a196b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ See implementation of `npyfile.save()`, in [npyfile.py](./npyfile.py)
- Complex numbers not supported
- Pickled data is not supported

NOT TESTED on unsupported/malformed/malicious inputs.

## TODO
Contributions welcomed!

TODO:

- Example code for loading/writing .npz files (Zip archives with .npy files)

- Add tests for unsupported/malformed inputs

## Developing

Expand Down
12 changes: 12 additions & 0 deletions examples/digits/read_requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import io
import requests
import npyfile

url = 'https://raw.githubusercontent.com/jonnor/micropython-npyfile/master/examples/digits/digits_labels.npy'

r = requests.get(url)
assert r.status_code == 200

shape, data = npyfile.load(io.BytesIO(r.content))
print(shape, data)

0 comments on commit 7a196b1

Please sign in to comment.