Skip to content

Commit ae87691

Browse files
committed
finish edits
1 parent 510c0f7 commit ae87691

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

source/integrations/fastapi-integration.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Use the following code to:
119119
db = client.get_database("college")
120120
student_collection = db.get_collection("students")
121121

122-
Define Your Database Models
122+
Create Your Database Models
123123
~~~~~~~~~~~~~~~~~~~~~~~~~~~
124124

125125
Our application has three models, the ``StudentModel``, the
@@ -246,7 +246,7 @@ Our application has three models, the ``StudentModel``, the
246246
Create Your Application Routes
247247
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248248

249-
Our application has five routes, as shown in the `running application homepage <http://127.0.0.1:8000/docs>`__:
249+
Our application has five routes:
250250

251251
.. list-table::
252252
:header-rows: 1
@@ -286,8 +286,8 @@ Our application has five routes, as shown in the `running application homepage <
286286
insert the student into our collection, we use the ``inserted_id`` to find
287287
the correct document and return this in our ``JSONResponse``.
288288

289-
FastAPI returns an HTTP ``200`` status code by default; but in this
290-
instance, a ``201`` created is more appropriate.
289+
FastAPI returns an HTTP ``200`` status code by default, but we will return a
290+
``201`` to explicitly that indicate the student has been created.
291291

292292
Define the ``create_student`` route using the following code:
293293

@@ -428,6 +428,12 @@ Our application has five routes, as shown in the `running application homepage <
428428

429429
.. step:: Delete Route
430430

431+
Because the ``delete_student`` is acting on a single document, we must
432+
supply an ``id`` in the URL. If we find a matching document and successfully
433+
delete it, then we return an HTTP status of ``204`` or "No Content." In
434+
this case, we do not return a document. If we cannot find a student with the
435+
specified ``id``, then we return a ``404`` error.
436+
431437
.. code-block:: python
432438

433439
@app.delete("/students/{id}", response_description="Delete a student")
@@ -442,17 +448,14 @@ Our application has five routes, as shown in the `running application homepage <
442448

443449
raise HTTPException(status_code=404, detail=f"Student {id} not found")
444450

445-
Our final route is ``delete_student``. Because this is acting on a single
446-
document, we must supply an ``id`` in the URL. If we find a matching
447-
document and successfully delete it, then we return an HTTP status of
448-
``204`` or "No Content." In this case, we do not return a document since
449-
we previously deleted it. However, if we cannot find a student with the specified ``id``, then
450-
we return a ``404``.
451+
After you complete these steps, you have a working application that
452+
uses FastAPI and the {+driver-async+} to connect to your MongoDB deployment, and
453+
manage student data.
451454

452455
More Resources
453456
--------------
454457

455-
For more information, see the following resources:
458+
For more information about FastAPI integration, see the following resources:
456459

457460
- MongoDB's Full Stack FastAPI App Generator:
458461
- `Blog post: Introducing the Full Stack FastAPI App Generator for Python Developers <https://www.mongodb.com/blog/post/introducing-full-stack-fast-api-app-generator-for-python-developers>`__

0 commit comments

Comments
 (0)