fastapi-cli 0.0.30__py3-none-any.whl → 0.0.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapi_cli/__init__.py +1 -1
- fastapi_cli/cli.py +65 -36
- {fastapi_cli-0.0.30.dist-info → fastapi_cli-0.0.32.dist-info}/METADATA +5 -1
- {fastapi_cli-0.0.30.dist-info → fastapi_cli-0.0.32.dist-info}/RECORD +7 -7
- {fastapi_cli-0.0.30.dist-info → fastapi_cli-0.0.32.dist-info}/WHEEL +0 -0
- {fastapi_cli-0.0.30.dist-info → fastapi_cli-0.0.32.dist-info}/entry_points.txt +0 -0
- {fastapi_cli-0.0.30.dist-info → fastapi_cli-0.0.32.dist-info}/licenses/LICENSE +0 -0
fastapi_cli/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.32"
|
fastapi_cli/cli.py
CHANGED
|
@@ -142,17 +142,19 @@ def _run(
|
|
|
142
142
|
proxy_headers: bool = False,
|
|
143
143
|
forwarded_allow_ips: str | None = None,
|
|
144
144
|
public_url: str | None = None,
|
|
145
|
+
verbose: bool = False,
|
|
145
146
|
) -> None:
|
|
146
147
|
with get_rich_toolkit() as toolkit:
|
|
147
148
|
server_type = "development" if command == "dev" else "production"
|
|
148
149
|
|
|
149
150
|
toolkit.print(f"Starting FastAPI in {server_type} mode", emoji="⚡️")
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
if verbose:
|
|
153
|
+
toolkit.print_line()
|
|
154
|
+
toolkit.print(
|
|
155
|
+
"Searching for package file structure from directories with [blue]__init__.py[/blue] files",
|
|
156
|
+
emoji="🔎",
|
|
157
|
+
)
|
|
156
158
|
|
|
157
159
|
if entrypoint and (path or app):
|
|
158
160
|
toolkit.print_line()
|
|
@@ -194,40 +196,54 @@ def _run(
|
|
|
194
196
|
|
|
195
197
|
module_data = import_data.module_data
|
|
196
198
|
import_string = import_data.import_string
|
|
199
|
+
is_auto_discovery = import_data.module_config_source == "auto-discovery"
|
|
197
200
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
+
if verbose:
|
|
202
|
+
toolkit.print_line()
|
|
203
|
+
toolkit.print(f"Importing from {module_data.extra_sys_path}", emoji="📂")
|
|
204
|
+
toolkit.print_line()
|
|
201
205
|
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
if module_data.module_paths:
|
|
207
|
+
root_tree = _get_module_tree(module_data.module_paths)
|
|
204
208
|
|
|
205
|
-
|
|
209
|
+
toolkit.print(root_tree)
|
|
206
210
|
|
|
207
|
-
|
|
211
|
+
toolkit.print_line()
|
|
212
|
+
|
|
213
|
+
toolkit.print(
|
|
214
|
+
"Importing the FastAPI app object from the module with the following code:",
|
|
215
|
+
)
|
|
216
|
+
toolkit.print_line()
|
|
217
|
+
toolkit.print(
|
|
218
|
+
f"[blue]from [bold]{module_data.module_import_str}[/bold] import [bold]{import_data.app_name}[/bold]",
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
# Outside --verbose, fold the resolution source into the import string
|
|
222
|
+
# line and point newcomers at --verbose for the full explanation
|
|
223
|
+
if is_auto_discovery and not verbose:
|
|
224
|
+
app_note = " [dim](auto-discovered, use --verbose to learn more)[/]"
|
|
225
|
+
else:
|
|
226
|
+
app_note = ""
|
|
208
227
|
|
|
209
|
-
toolkit.print(
|
|
210
|
-
"Importing the FastAPI app object from the module with the following code:",
|
|
211
|
-
)
|
|
212
228
|
toolkit.print_line()
|
|
213
229
|
toolkit.print(
|
|
214
|
-
f"[blue]
|
|
230
|
+
f"Using import string: [blue]{import_string}[/]{app_note}", emoji="🐍"
|
|
215
231
|
)
|
|
216
232
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
toolkit.print(f"• Module: {mod_source_desc}")
|
|
228
|
-
toolkit.print(f"• App name: {app_source_desc}")
|
|
233
|
+
if verbose:
|
|
234
|
+
toolkit.print_line()
|
|
235
|
+
mod_source_desc = SOURCE_DESCRIPTIONS[import_data.module_config_source]
|
|
236
|
+
app_source_desc = SOURCE_DESCRIPTIONS[import_data.app_name_config_source]
|
|
237
|
+
toolkit.print("Configuration sources:", emoji="📋")
|
|
238
|
+
if mod_source_desc == app_source_desc:
|
|
239
|
+
toolkit.print(f"• Import string: {mod_source_desc}")
|
|
240
|
+
else:
|
|
241
|
+
toolkit.print(f"• Module: {mod_source_desc}")
|
|
242
|
+
toolkit.print(f"• App name: {app_source_desc}")
|
|
229
243
|
|
|
230
|
-
|
|
244
|
+
# Nudge to pin the entrypoint whenever it was auto-discovered, so it's
|
|
245
|
+
# explicit next time — shown in the default output, not just --verbose
|
|
246
|
+
if is_auto_discovery:
|
|
231
247
|
toolkit.print_line()
|
|
232
248
|
toolkit.print(
|
|
233
249
|
"You can configure an entrypoint in [blue]pyproject.toml[/] for this app with:",
|
|
@@ -252,13 +268,6 @@ def _run(
|
|
|
252
268
|
toolkit.print(f"Server started at [link={url}]{url}[/]", emoji="🌐")
|
|
253
269
|
toolkit.print(f"Documentation at [link={url_docs}]{url_docs}[/]")
|
|
254
270
|
|
|
255
|
-
if command == "dev":
|
|
256
|
-
toolkit.print_line()
|
|
257
|
-
toolkit.print(
|
|
258
|
-
"Running in development mode, for production use: [bold]fastapi run[/]",
|
|
259
|
-
emoji="💡",
|
|
260
|
-
)
|
|
261
|
-
|
|
262
271
|
if not uvicorn:
|
|
263
272
|
raise FastAPICLIException(
|
|
264
273
|
"Could not import Uvicorn, try running 'pip install uvicorn'"
|
|
@@ -356,6 +365,14 @@ def dev(
|
|
|
356
365
|
help="Comma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything."
|
|
357
366
|
),
|
|
358
367
|
] = None,
|
|
368
|
+
verbose: Annotated[
|
|
369
|
+
bool,
|
|
370
|
+
typer.Option(
|
|
371
|
+
"--verbose",
|
|
372
|
+
"-v",
|
|
373
|
+
help="Show detailed startup output and debug logs: how the [bold]FastAPI[/bold] app was discovered, imported, and configured.",
|
|
374
|
+
),
|
|
375
|
+
] = False,
|
|
359
376
|
) -> Any:
|
|
360
377
|
"""
|
|
361
378
|
Run a [bold]FastAPI[/bold] app in [yellow]development[/yellow] mode. 🧪
|
|
@@ -382,6 +399,8 @@ def dev(
|
|
|
382
399
|
|
|
383
400
|
Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module or package.
|
|
384
401
|
"""
|
|
402
|
+
os.environ.setdefault("FASTAPI_ENV", "development")
|
|
403
|
+
|
|
385
404
|
_run(
|
|
386
405
|
path=path,
|
|
387
406
|
host=host,
|
|
@@ -395,6 +414,7 @@ def dev(
|
|
|
395
414
|
proxy_headers=proxy_headers,
|
|
396
415
|
forwarded_allow_ips=forwarded_allow_ips,
|
|
397
416
|
public_url=os.getenv("FASTAPI_PUBLIC_URL"),
|
|
417
|
+
verbose=verbose,
|
|
398
418
|
)
|
|
399
419
|
|
|
400
420
|
|
|
@@ -464,6 +484,14 @@ def run(
|
|
|
464
484
|
help="Comma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything."
|
|
465
485
|
),
|
|
466
486
|
] = None,
|
|
487
|
+
verbose: Annotated[
|
|
488
|
+
bool,
|
|
489
|
+
typer.Option(
|
|
490
|
+
"--verbose",
|
|
491
|
+
"-v",
|
|
492
|
+
help="Show detailed startup output and debug logs: how the [bold]FastAPI[/bold] app was discovered, imported, and configured.",
|
|
493
|
+
),
|
|
494
|
+
] = False,
|
|
467
495
|
) -> Any:
|
|
468
496
|
"""
|
|
469
497
|
Run a [bold]FastAPI[/bold] app in [green]production[/green] mode. 🚀
|
|
@@ -503,6 +531,7 @@ def run(
|
|
|
503
531
|
proxy_headers=proxy_headers,
|
|
504
532
|
forwarded_allow_ips=forwarded_allow_ips,
|
|
505
533
|
public_url=os.getenv("FASTAPI_PUBLIC_URL"),
|
|
534
|
+
verbose=verbose,
|
|
506
535
|
)
|
|
507
536
|
|
|
508
537
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.32
|
|
4
4
|
Summary: Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
|
|
5
5
|
Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -121,6 +121,10 @@ By default, it will have **auto-reload** enabled, so it will automatically reloa
|
|
|
121
121
|
|
|
122
122
|
By default it will listen on the IP address `127.0.0.1`, which is the IP for your machine to communicate with itself alone (`localhost`).
|
|
123
123
|
|
|
124
|
+
Before importing your app, `fastapi dev` sets the `FASTAPI_ENV` environment variable to `development`. If `FASTAPI_ENV` is already set, its existing value is preserved. This lets app startup code choose development-friendly behavior while allowing you to provide an app-specific environment such as `staging`.
|
|
125
|
+
|
|
126
|
+
The conventional `FASTAPI_ENV` values are `development` and `production`. `fastapi run` currently leaves `FASTAPI_ENV` unchanged, so set it explicitly if your app needs to detect production mode.
|
|
127
|
+
|
|
124
128
|
## `fastapi run`
|
|
125
129
|
|
|
126
130
|
When you run `fastapi run`, it will run on production mode by default.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
fastapi_cli-0.0.
|
|
2
|
-
fastapi_cli-0.0.
|
|
3
|
-
fastapi_cli-0.0.
|
|
4
|
-
fastapi_cli-0.0.
|
|
5
|
-
fastapi_cli/__init__.py,sha256=
|
|
1
|
+
fastapi_cli-0.0.32.dist-info/METADATA,sha256=71R4xArHh0pgfdHwl3mubD4MWyThkML0kSBmUdHjApE,6698
|
|
2
|
+
fastapi_cli-0.0.32.dist-info/WHEEL,sha256=VP-D4TPS230sME9Z3vb3INXvo1yt0924YRm5AOsk_dE,90
|
|
3
|
+
fastapi_cli-0.0.32.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
|
4
|
+
fastapi_cli-0.0.32.dist-info/licenses/LICENSE,sha256=FqD5B4VbXJnefprQseE0U8llL6FxojC-i8muZy7YmSU,1086
|
|
5
|
+
fastapi_cli/__init__.py,sha256=WKDnjJM7gYpD9fIwhK2qAZICJAT2ndquQ6VcOar074Y,23
|
|
6
6
|
fastapi_cli/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
|
|
7
|
-
fastapi_cli/cli.py,sha256=
|
|
7
|
+
fastapi_cli/cli.py,sha256=OJda3zu6Qb9mczvaX_443LuwBVqf82504TE4Z4ucVK8,18216
|
|
8
8
|
fastapi_cli/config.py,sha256=o-yPktLddeMGSX25VjOg3W8I-jidDF9SQccpPpwpQt4,1463
|
|
9
9
|
fastapi_cli/discover.py,sha256=dXH63dQ_bKLF0GQFIxWfHKDhTyFZWBpkyzPyoLLCSko,5472
|
|
10
10
|
fastapi_cli/exceptions.py,sha256=AHRSqd43fbqN5IpX-Fq389k9MoEK_q28wVFL7oqPNcc,47
|
|
@@ -12,4 +12,4 @@ fastapi_cli/logging.py,sha256=_gMopiUSunAhBT7nuafiVLeQV-hEmswPifV_l16tpH4,653
|
|
|
12
12
|
fastapi_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
fastapi_cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
fastapi_cli/utils/cli.py,sha256=qH_DXQahKpWF3Zara_E_6YVuaz30ztVch0dQAJoXRVY,5702
|
|
15
|
-
fastapi_cli-0.0.
|
|
15
|
+
fastapi_cli-0.0.32.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|