ClimenteA / flaskwebgui

Create desktop applications with Flask/Django/FastAPI!
MIT License
718 stars 71 forks source link

Prevent users from opening multiple apps at the same time #136

Closed Sunyang12345678 closed 7 months ago

Sunyang12345678 commented 8 months ago

image In flaskwebgui, is there any command support that prohibits users from opening multiple applications at the same time? After opening the application, when the user clicks again, a dialog box will pop up to tell the user that the current application is already open.

ClimenteA commented 8 months ago

Some value saved in temp folder indicating that the app is opened/closed could be added to add this option. Feel free to make a PR for this issue and the other one you opened (I don't have much time at the moment).

williamjmorenor commented 7 months ago

I think that if the app set a port a check that this port is already in use (the server that was started by the firts instance should be using it) can help. I think the temp file can not be a solutions if the app is stoped with no time to delete this file and may cause the next startup to file.

ClimenteA commented 7 months ago

Checking if flaskwebgui has a port open may indeed be a better solution. Maybe I can set process name for flaskwebgui on startup to make that work.

ClimenteA commented 7 months ago

Did a little bit of digging and I saw that the second/third etc instances of the app didn't worked. Only first instance of the app worked. I separated the profile browser data for each app instance run so now all open instances will work.

Unfortunately, allowing only one window open is not possible without causing side effects.

Ex: If pc/laptop is shutdown we don't have control over the state of the app (open, closed). It will be considered in open state and if only one instance is allowed - app will not open. Having fixed ports on flaskwebgui is tricky you may have running processes on that port.