CLI 0.0.14, Uvicorn update and no more [serve] (#12845)

Calls uvicorn directly from cli:
Reload works if you define app by import string instead of object.
(was doing subprocess in order to get reloading)

Version bump to 0.0.14

Remove the need for [serve] for simplicity.

Readmes are updated in #12847 to avoid cluttering this PR
This commit is contained in:
Erick Friis
2023-11-03 11:05:52 -07:00
committed by GitHub
parent 76bcac5bb3
commit 1bc35f61cb
5 changed files with 56 additions and 57 deletions

View File

@@ -220,8 +220,10 @@ def serve(
"""
app_str = app if app is not None else "app.server:app"
port_str = str(port) if port is not None else "8000"
host_str = host if host is not None else "127.0.0.1"
cmd = ["uvicorn", app_str, "--reload", "--port", port_str, "--host", host_str]
subprocess.run(cmd)
import uvicorn
uvicorn.run(
app_str, host=host_str, port=port if port is not None else 8000, reload=True
)