view.py
view.py copied to clipboard
Server-Side HTTP Client
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
Waiting on #12
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.
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.