justpy icon indicating copy to clipboard operation
justpy copied to clipboard

Add uvicorn reload configuration parameter to Justpy

Open platinops opened this issue 5 years ago • 4 comments

Uvicorn has the ability to automatically restart the server when a file changes.

I currently use this functionality by starting the uvicorn server as follows (while adding the argument start_server=False to the justpy command):

uvicorn.run("main:app", host="127.0.0.1", port=8080, log_level="warning", reload=True)

Is it possible to add this option to the justpy command itself (and configuration variables)?

platinops avatar Oct 11 '20 09:10 platinops

I'll add this feature in one of the next versions.

elimintz avatar Oct 12 '20 04:10 elimintz

When I run using uvicorn as stated in my previous post, JustPy still outputs JustPy ready to go on http://{HOST}:{PORT}, despite start_server=False.

So I believe this line in the justpy_startup function should actually only be executed when start_server=True:

print(f'JustPy ready to go on http://{HOST}:{PORT}')

platinops avatar Oct 29 '20 15:10 platinops

Yes, I agree. However that is printed as the last statement of the startup and that function does not have access to start_server. Since users that run uvicorn from the command line are advanced users, I don't think this will throw them off. In any case I will check if there is a simple solution.

elimintz avatar Oct 30 '20 02:10 elimintz

I this going to be in 0.3.0?

WolfgangFahl avatar Aug 20 '22 10:08 WolfgangFahl

If you have this need you might want to migrate to nicegui

WolfgangFahl avatar Sep 20 '23 09:09 WolfgangFahl