uvicorn icon indicating copy to clipboard operation
uvicorn copied to clipboard

Add example how to run the server programmatically with reload

Open SergeyTsaplin opened this issue 3 years ago • 6 comments

Add an example of how to run the uvicorn with the reload option programmatically.

SergeyTsaplin avatar Jul 12 '22 12:07 SergeyTsaplin

Anybody here?

SergeyTsaplin avatar Jul 14 '22 14:07 SergeyTsaplin

yes

Kludex avatar Jul 14 '22 14:07 Kludex

We'll check shortly. Thanks for the PR! 🙏

Kludex avatar Jul 14 '22 14:07 Kludex

Well... You just made me noticed that we have a "Running programmatically" section on both pages on our documentation.

image

🤦‍♂️

Kludex avatar Jul 19 '22 17:07 Kludex

Well... You just made me noticed that we have a "Running programmatically" section on both pages on our documentation.

image

So, should I add the same example to the second page?

SergeyTsaplin avatar Jul 19 '22 22:07 SergeyTsaplin

I'll think about this, and get back here. The documentation structure may need some small changes.

Kludex avatar Jul 22 '22 15:07 Kludex

I think I'm going to have to patch the docs before the release...

@SergeyTsaplin Why not the following?

if __name__ == "__main__":
    uvicorn.run(
        "main:app",
        host="127.0.0.1",
        port=8000,
        log_level="info",
        reload=True,
    )

Kludex avatar Oct 28 '22 17:10 Kludex