Combining Flet with a Python backend framework. #752
Replies: 2 comments 2 replies
-
Currently, Flet is a server-side framework, but the whole point of FastAPI and such is to provide backend services to a frontend app via JSON. It would have more sense if there is an ability to host Flet app inside FastAPI and call its services directly without HTTP overhead. We are working on a "light" version of Flet server written in Python which, I believe, could be hosted inside FastAPI. |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I understand exactly what you're trying to achieve, but I played with Flet and FastAPI yesterday, and I found an interesting solution to dynamically render Flet controls from JSON data sent by the FastAPI server. Here's the example server code:
And the Flet client:
Now, it depends on how you want to structure the JSON, but as long as you use dictionary key that is the same as a Flet control property name, this can work almost universally. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have been wondering how anyone would combine Flet and a Python web framework such as FastAPI, DRF, Flask etc. Currently, I have built a Django-Ninja API and would like to use Flet, for the interfaces.
My major concern though, is figuring out how to architect the codebase in terms of structure and also deployment (e.g I was thinking deploy the Flet app to fly.io which would be consuming the API deployed to Render or DO etc.) Or is there a way to have Flet render the frontend parts of the app as Templates do and then have a single app deployment
I'd appreciate a guide on this.
Beta Was this translation helpful? Give feedback.
All reactions