Python uv 安装 FastAPI

Python FastAPI About 2,472 words

初始化项目

uv init my-demo

添加依赖

uv add fastapi[standard]

开发模式运行 FastAPI

uv run fastapi dev

生产模式运行 FastAPI

默认监听8000端口。

fastapi run

--port指定端口。

fastapi run main.py --host 0.0.0.0 --port 8000

worker运行。注意共享变量。

fastapi run --workers 4 main.py

更多 FastAPI CLI 参数

C:\code\python\my-demo>fastapi -h

 Usage: fastapi [OPTIONS] COMMAND [ARGS]...

 FastAPI CLI - The fastapi command line app. 😎

 Manage your FastAPI projects, run your FastAPI apps, and more.

 Read more in the docs: https://fastapi.tiangolo.com/fastapi-cli/.

╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version                                   Show the version and exit.                                                            │
│ --verbose                 --no-verbose      Enable verbose output [default: no-verbose]                                           │
│ --install-completion                        Install completion for the current shell.                                             │
│ --show-completion                           Show completion for the current shell, to copy it or customize the installation.      │
│ --help                -h                    Show this message and exit.                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ dev     Run a FastAPI app in development mode. 🧪                                                                                 │
│ run     Run a FastAPI app in production mode. 🚀                                                                                  │
│ deploy  Deploy a FastAPI app to FastAPI Cloud. 🚀                                                                                 │
│ login   Login to FastAPI Cloud. 🚀                                                                                                │
│ cloud   Manage FastAPI Cloud deployments. 🚀                                                                                      │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

官方文档

https://fastapi.tiangolo.com

GitHub

https://github.com/FastAPI/FastAPI

Views: 8 · Posted: 2026-06-15

———         Thanks for Reading         ———

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓
Prev Post
Today In History
Browsing Refresh