From c91c99b35e6b04fb369241487363e7192fe9849b Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 29 Aug 2024 22:22:37 -0500 Subject: [PATCH] Drop old content from the FastAPI guide (#6851) --- docs/guides/integration/fastapi.md | 48 ++++-------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/docs/guides/integration/fastapi.md b/docs/guides/integration/fastapi.md index a62c861a1..4fd923e51 100644 --- a/docs/guides/integration/fastapi.md +++ b/docs/guides/integration/fastapi.md @@ -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`: