view.py icon indicating copy to clipboard operation
view.py copied to clipboard

Server-Side HTTP Client

Open ZeroIntensity opened this issue 2 years ago • 3 comments

Feature description

NextJS has their own way of handling fetching from servers by caching the request. It shouldn't be super hard to implement this for view.

Feature example API

from view import new_app

app = new_app()

@app.get("/")
async def index():
    res = await app.http.get("https://google.com")
    ...
app.run()

OR, a utility that calls get_app internally

from view import get, http

client = http()

@get("/")
async def index():
    res = await client.get("https://google.com")
    ...

Anything else?

No response

ZeroIntensity avatar Nov 29 '23 15:11 ZeroIntensity

Waiting on #12

ZeroIntensity avatar Dec 27 '23 06:12 ZeroIntensity

This is no longer a beginner issue. This should involve the PyAwaitable API (details in #19) and likely implement HTTP internally. This is also now waiting on #109.

This will involve OS API's in C, so some macro magic might be needed in order to make it cross platform.

ZeroIntensity avatar Dec 30 '23 20:12 ZeroIntensity

On a second thought, reimplementing HTTP is probably a terrible idea. cURL could be shipped with view.py for an HTTP client. This might cause some blocking I/O problems, though.

It might be a good idea to forget about implementing this in C - using aiohttp and just adding caching to it could be useful.

ZeroIntensity avatar May 15 '24 15:05 ZeroIntensity