Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher level api that abstracts away FastAPI #305

Open
jimkring opened this issue May 4, 2024 · 2 comments
Open

Higher level api that abstracts away FastAPI #305

jimkring opened this issue May 4, 2024 · 2 comments

Comments

@jimkring
Copy link
Contributor

jimkring commented May 4, 2024

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.

@jimkring jimkring changed the title fastui app/router decorator that prefixes /api for page urls Higher level api that abstracts away FastAPI May 4, 2024
@hasansezertasan
Copy link

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.

@jimkring
Copy link
Contributor Author

jimkring commented May 5, 2024

@hasansezertasan good point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants