Httpx File 0.2.0 | Coderz Repository

httpx-file 0.2.0

Last updated:

0 purchases

httpx-file 0.2.0 Image
httpx-file 0.2.0 Images

Free

Languages

Categories

Add to Cart

Description:

httpxfile 0.2.0

httpx-file
Transport adapter fort httpx to allow
file:// URI fetching in the local filesystem.
Installation
pip install httpx-file

Usage
Synchronous
httpx-file subclasses httpx.Client, so you can just replace httpx.Client
with httpx_file.Client to get the same behavior with added file:// protocol
support.
from httpx_file import Client

client = Client()
client.get('file:///etc/fstab)

Or you can also mount FileTransport in a httpx.Client instance.
from httpx_file import FileTransport
from httpx import Client

client = Client(mounts={'file://': FileTransport()})
client.get('file:///etc/fstab)

Asynchronous
It is also possible to use httpx-file possibilities asynchronous way.
To do this, you can just replace 'httpx.AsyncClient' with 'httpx_file.AsyncClient'.
from httpx_file import AsyncClient

# Taken from tests/test_transport.py

from pathlib import Path

THIS = Path(__file__)

async def test_async_client():
async_client = AsyncClient()
async_response = await async_client.get(THIS.as_uri())

assert async_response.content == THIS.read_bytes()

Or you can also mount FileTransport in a httpx.AsyncClient instance.
from httpx_file import FileTransport
from httpx import AsyncClient

client = AsyncClient(mounts={'file://': FileTransport()})
client.get('file:///etc/fstab)

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.