Hi there,
I'm trying to test whether a python app built with NiceGUI will work on Posit Connect (I can't find any mention of the two together) before I get into learning it proper. NiceGUI is built on FastAPI so I hope it should work, but I'm currently stuck.
I'm just trying to upload the basic demo:
# app.py
from nicegui import ui
ui.label('Hello NiceGUI!')
ui.run()
I'm deploying it with:
rsconnect deploy fastapi -n rconnect --entrypoint app .
The deployment works but I get the following error on the Posit Connect logs when the app tries to start
2023/10/11 22:55:43.243207611 ERROR: Traceback (most recent call last):
2023/10/11 22:55:43.243245111 File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/starlette/routing.py", line 677, in lifespan
2023/10/11 22:55:43.243275296 async with self.lifespan_context(app) as maybe_state:
2023/10/11 22:55:43.243276348 File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/starlette/routing.py", line 566, in __aenter__
2023/10/11 22:55:43.243296243 await self._router.startup()
2023/10/11 22:55:43.243306350 File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/starlette/routing.py", line 656, in startup
2023/10/11 22:55:43.243311926 handler()
2023/10/11 22:55:43.243312770 File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/nicegui/nicegui.py", line 75, in handle_startup
2023/10/11 22:55:43.243317822 raise RuntimeError('\n\n'
2023/10/11 22:55:43.243318250 RuntimeError:
2023/10/11 22:55:43.243322835
2023/10/11 22:55:43.243323595 You must call ui.run() to start the server.
2023/10/11 22:55:43.243330081 If ui.run() is behind a main guard
2023/10/11 22:55:43.243330511 if __name__ == "__main__":
2023/10/11 22:55:43.243334291 remove the guard or replace it with
2023/10/11 22:55:43.243334726 if __name__ in {"__main__", "__mp_main__"}:
2023/10/11 22:55:43.243338471 to allow for multiprocessing.
2023/10/11 22:55:43.243338936
I've also tried
# app.py
from nicegui import ui
ui.label('Hello NiceGUI!')
app = ui.run()
and deploying it with:
rsconnect deploy fastapi -n rconnect --entrypoint app:app .
Any help would be greatly appreciated