mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Drop old content from the FastAPI guide (#6851)
This commit is contained in:
parent
9f8ebca941
commit
c91c99b35e
1 changed files with 5 additions and 43 deletions
|
@ -27,18 +27,18 @@ follows:
|
|||
│ └── admin.py
|
||||
```
|
||||
|
||||
To migrate this project to uv, add a `pyproject.toml` file to the root directory of the project with
|
||||
To use uv with this project, add a `pyproject.toml` file to the root directory of the project with
|
||||
`uv init`:
|
||||
|
||||
```console
|
||||
$ uv init
|
||||
$ uv add fastapi --extra standard
|
||||
```
|
||||
|
||||
!!! tip
|
||||
Then, add a dependency on FastAPI:
|
||||
|
||||
If you have an existing `pyproject.toml`, `uv init` cannot be used — but you may not need to
|
||||
make any changes to the file.
|
||||
```console
|
||||
$ uv add fastapi --extra standard
|
||||
```
|
||||
|
||||
You should now have the following structure:
|
||||
|
||||
|
@ -82,44 +82,6 @@ $ uv run fastapi dev
|
|||
alongside the `pyproject.toml`), create a virtual environment, and run the command in that
|
||||
environment.
|
||||
|
||||
## Initializing a FastAPI project
|
||||
|
||||
We could reach a similar result to the above by creating a project from scratch with `uv init` and
|
||||
installing FastAPI with `uv add fastapi`, as in:
|
||||
|
||||
```console
|
||||
$ uv init app
|
||||
$ cd app
|
||||
$ uv add fastapi --extra standard
|
||||
```
|
||||
|
||||
By default, uv uses a `src` layout for newly-created projects, so the `app` directory will be nested
|
||||
within a `src` directory. If you copied over the source code from the FastAPI tutorial, the project
|
||||
structure would look like this:
|
||||
|
||||
```plaintext
|
||||
.
|
||||
├── pyproject.toml
|
||||
└── src
|
||||
└── app
|
||||
├── __init__.py
|
||||
├── main.py
|
||||
├── dependencies.py
|
||||
└── routers
|
||||
│ ├── __init__.py
|
||||
│ ├── items.py
|
||||
│ └── users.py
|
||||
└── internal
|
||||
├── __init__.py
|
||||
└── admin.py
|
||||
```
|
||||
|
||||
In this case, you would run the FastAPI application with:
|
||||
|
||||
```console
|
||||
$ uv run fastapi dev src/app/main.py
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
To deploy the FastAPI application with Docker, you can use the following `Dockerfile`:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue