1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-04 14:35:24 +02:00
tldr/pages/common/fastapi.md

29 lines
672 B
Markdown
Raw Normal View History

2025-06-29 22:12:37 +05:30
# fastapi
2025-06-29 22:41:59 +05:30
> Run FastAPI apps which uses Uvicorn under the hood.
2025-06-29 23:15:08 +05:30
> More information: <https://manned.org/fastapi>.
2025-06-29 22:12:37 +05:30
- Run a FastAPI app with automatic reload (for development):
2025-06-29 23:15:08 +05:30
`fastapi run {{path/to/file.py}} --reload`
2025-06-29 22:12:37 +05:30
2025-06-29 23:15:08 +05:30
- Serve your app in both development mode:
2025-06-29 22:12:37 +05:30
2025-06-29 23:15:08 +05:30
`fastapi dev {{path/to/file.py}}`
2025-06-29 22:12:37 +05:30
- Specify the host and port to run on:
2025-06-29 23:15:08 +05:30
`fastapi run {{path/to/file.py}} --host {{host_address}} --port {{port}}`
2025-06-29 22:12:37 +05:30
- Set the app variable name (if not `app`) or specify a custom app directory:
2025-06-29 23:15:08 +05:30
`fastapi run {{path/to/file.py}} --app-dir {{path/to/app}} --app {{custom_app_name}}`
2025-06-29 22:12:37 +05:30
2025-06-29 23:15:08 +05:30
- Display help:
2025-06-29 22:12:37 +05:30
`fastapi --help`
- Display help for a subcommand:
`fastapi run --help`