You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/fastapi_cli/cli.py
+34-17Lines changed: 34 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -195,39 +195,44 @@ def dev(
195
195
path: Annotated[
196
196
Union[Path, None],
197
197
typer.Argument(
198
-
help="A path to a Python file or package directory (with [blue]__init__.py[/blue] files) containing a [bold]FastAPI[/bold] app. If not provided, a default set of paths will be tried."
198
+
help="A path to a Python file or package directory (with [blue]__init__.py[/blue] files) containing a [bold]FastAPI[/bold] app. If not provided, a default set of paths will be tried.",
199
+
envvar="FASTAPI_PATH",
199
200
),
200
201
] =None,
201
202
*,
202
203
host: Annotated[
203
204
str,
204
205
typer.Option(
205
-
help="The host to serve on. For local development in localhost use [blue]127.0.0.1[/blue]. To enable public access, e.g. in a container, use all the IP addresses available with [blue]0.0.0.0[/blue]."
206
+
help="The host to serve on. For local development in localhost use [blue]127.0.0.1[/blue]. To enable public access, e.g. in a container, use all the IP addresses available with [blue]0.0.0.0[/blue].",
207
+
envvar="FASTAPI_HOST",
206
208
),
207
209
] ="127.0.0.1",
208
210
port: Annotated[
209
211
int,
210
212
typer.Option(
211
213
help="The port to serve on. You would normally have a termination proxy on top (another program) handling HTTPS on port [blue]443[/blue] and HTTP on port [blue]80[/blue], transferring the communication to your app.",
212
-
envvar="PORT",
214
+
envvar="FASTAPI_PORT",
213
215
),
214
216
] =8000,
215
217
reload: Annotated[
216
218
bool,
217
219
typer.Option(
218
-
help="Enable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development."
220
+
help="Enable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development.",
221
+
envvar="FASTAPI_RELOAD",
219
222
),
220
223
] =True,
221
224
root_path: Annotated[
222
225
str,
223
226
typer.Option(
224
-
help="The root path is used to tell your app that it is being served to the outside world with some [bold]path prefix[/bold] set up in some termination proxy or similar."
227
+
help="The root path is used to tell your app that it is being served to the outside world with some [bold]path prefix[/bold] set up in some termination proxy or similar.",
228
+
envvar="FASTAPI_ROOTPATH",
225
229
),
226
230
] ="",
227
231
app: Annotated[
228
232
Union[str, None],
229
233
typer.Option(
230
-
help="The name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically."
234
+
help="The name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically.",
235
+
envvar="FASTAPI_APP",
231
236
),
232
237
] =None,
233
238
entrypoint: Annotated[
@@ -236,18 +241,21 @@ def dev(
236
241
"--entrypoint",
237
242
"-e",
238
243
help="The FastAPI app import string in the format 'some.importable_module:app_name'.",
244
+
envvar="FASTAPI_ENTRYPOINT",
239
245
),
240
246
] =None,
241
247
proxy_headers: Annotated[
242
248
bool,
243
249
typer.Option(
244
-
help="Enable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info."
250
+
help="Enable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info.",
251
+
envvar="FASTAPI_PROXY_HEADERS",
245
252
),
246
253
] =True,
247
254
forwarded_allow_ips: Annotated[
248
255
Union[str, None],
249
256
typer.Option(
250
-
help="Comma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything."
257
+
help="Comma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything.",
258
+
envvar="FASTAPI_FORWARDED_ALLOW_IPS",
251
259
),
252
260
] =None,
253
261
) ->Any:
@@ -295,45 +303,51 @@ def run(
295
303
path: Annotated[
296
304
Union[Path, None],
297
305
typer.Argument(
298
-
help="A path to a Python file or package directory (with [blue]__init__.py[/blue] files) containing a [bold]FastAPI[/bold] app. If not provided, a default set of paths will be tried."
306
+
help="A path to a Python file or package directory (with [blue]__init__.py[/blue] files) containing a [bold]FastAPI[/bold] app. If not provided, a default set of paths will be tried.",
307
+
envvar="FASTAPI_PATH",
299
308
),
300
309
] =None,
301
310
*,
302
311
host: Annotated[
303
312
str,
304
313
typer.Option(
305
-
help="The host to serve on. For local development in localhost use [blue]127.0.0.1[/blue]. To enable public access, e.g. in a container, use all the IP addresses available with [blue]0.0.0.0[/blue]."
314
+
help="The host to serve on. For local development in localhost use [blue]127.0.0.1[/blue]. To enable public access, e.g. in a container, use all the IP addresses available with [blue]0.0.0.0[/blue].",
315
+
envvar="FASTAPI_HOST",
306
316
),
307
317
] ="0.0.0.0",
308
318
port: Annotated[
309
319
int,
310
320
typer.Option(
311
321
help="The port to serve on. You would normally have a termination proxy on top (another program) handling HTTPS on port [blue]443[/blue] and HTTP on port [blue]80[/blue], transferring the communication to your app.",
312
-
envvar="PORT",
322
+
envvar="FASTAPI_PORT",
313
323
),
314
324
] =8000,
315
325
reload: Annotated[
316
326
bool,
317
327
typer.Option(
318
-
help="Enable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development."
328
+
help="Enable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development.",
329
+
envvar="FASTAPI_RELOAD",
319
330
),
320
331
] =False,
321
332
workers: Annotated[
322
333
Union[int, None],
323
334
typer.Option(
324
-
help="Use multiple worker processes. Mutually exclusive with the --reload flag."
335
+
help="Use multiple worker processes. Mutually exclusive with the --reload flag.",
336
+
envvar="FASTAPI_WORKERS",
325
337
),
326
338
] =None,
327
339
root_path: Annotated[
328
340
str,
329
341
typer.Option(
330
-
help="The root path is used to tell your app that it is being served to the outside world with some [bold]path prefix[/bold] set up in some termination proxy or similar."
342
+
help="The root path is used to tell your app that it is being served to the outside world with some [bold]path prefix[/bold] set up in some termination proxy or similar.",
343
+
envvar="FASTAPI_ROOTPATH",
331
344
),
332
345
] ="",
333
346
app: Annotated[
334
347
Union[str, None],
335
348
typer.Option(
336
-
help="The name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically."
349
+
help="The name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically.",
350
+
envvar="FASTAPI_APP",
337
351
),
338
352
] =None,
339
353
entrypoint: Annotated[
@@ -342,18 +356,21 @@ def run(
342
356
"--entrypoint",
343
357
"-e",
344
358
help="The FastAPI app import string in the format 'some.importable_module:app_name'.",
359
+
envvar="FASTAPI_ENTRYPOINT",
345
360
),
346
361
] =None,
347
362
proxy_headers: Annotated[
348
363
bool,
349
364
typer.Option(
350
-
help="Enable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info."
365
+
help="Enable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info.",
366
+
envvar="FASTAPI_PROXY_HEADERS",
351
367
),
352
368
] =True,
353
369
forwarded_allow_ips: Annotated[
354
370
Union[str, None],
355
371
typer.Option(
356
-
help="Comma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything."
372
+
help="Comma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything.",
0 commit comments