Higher level api that abstracts away FastAPI
Maybe it's just me, but I think it would be nice if FastUI also had a slightly higher level of abstraction that encapsulates FastAPI, for cases where one does not want/need to work directly with FastAPI.
Here's what I'm thinking...
Right now, I have to do this:
# use fastapi directly and understand how to map FastUI into FastAPI
from fastapi import FastAPI
app = FastAPI()
@app.get("/api/user/{id}/", response_model=FastUI, response_model_exclude_none=True)`
def user_detail(id: int) -> list[AnyComponent]:
...
What I'd love to be able to do is something like this:
# use FastUI directly and encapsulate how it works with FastAPI
from fastui import FastUI
app = FastUI()
@app.get("/user/{id}/")
def user_detail(id: int) -> FastUIPage:
...
When I have a lot of different pages, the simplified api would be DRY'er.
All sounds good but AFAIK FastUI aims to be a framework (most probably language) agnostic tool.
Quoting README.md:
While it works well with FastAPI it doesn't depend on FastAPI, and most of it could be used with any Python web framework.
Depending on the README, I could say that "your request is irrelevant".
PS: I don't think encapsulating FastAPI is not a good idea. It doesn't bring anything to the table, except reducing imports to one or maybe two lines.
@hasansezertasan good point!