flet-dev / examples

Flet sample applications
MIT License
449 stars 183 forks source link

need asynchronous network request demo #146

Open BrentHuang opened 1 month ago

BrentHuang commented 1 month ago

I have a web application. When I click the login button on the page, it sends an HTTP post request to the server and then receive the response from the server. The whole process is required to be asynchronous. While waiting for the server to respond, a loading animation is placed on the page.

Can you give me a demo of this scenario?

Finally, I will use flet build web to package and deploy this web application.

BrentHuang commented 1 month ago

When the web application starts, I create a session by session = aiohttp.ClientSession().

Then, in each page of the web application, I use this session object to communicate with the server.

When the web application exits, I want to call await session.close(). How can I do this?