diff --git a/docs/deployment.md b/docs/deployment.md index d2e94b7ea..6ff8144f1 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -87,6 +87,9 @@ Options: [default: TLSv1] --header TEXT Specify custom default HTTP response headers as a Name:Value pair + --app-dir TEXT Look for APP in the specified directory, by + adding this to the PYTHONPATH. Defaults to + the current working directory. --help Show this message and exit. ``` diff --git a/uvicorn/main.py b/uvicorn/main.py index 7d63c0f77..25eb54adb 100644 --- a/uvicorn/main.py +++ b/uvicorn/main.py @@ -256,6 +256,13 @@ def print_version(ctx, param, value): is_eager=True, help="Display the uvicorn version and exit.", ) +@click.option( + "--app-dir", + "app_dir", + default=".", + show_default=True, + help="Look for APP in the specified directory, by adding this to the PYTHONPATH. Defaults to the current working directory.", +) def main( app, host: str, @@ -290,8 +297,9 @@ def main( ssl_ciphers: str, headers: typing.List[str], use_colors: bool, + app_dir: str, ): - sys.path.insert(0, ".") + sys.path.insert(0, app_dir) kwargs = { "app": app,