0% found this document useful (0 votes)
3 views2 pages

Fast API

The document provides an introduction to Fast API, including its definition and HTTP methods such as GET, POST, PUT, and DELETE. It explains path parameters and query parameters, detailing how to define and use them in API requests. An example of a GET request to view a patient by ID is also included, demonstrating error handling for non-existent patients.

Uploaded by

forex15701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Fast API

The document provides an introduction to Fast API, including its definition and HTTP methods such as GET, POST, PUT, and DELETE. It explains path parameters and query parameters, detailing how to define and use them in API requests. An example of a GET request to view a patient by ID is also included, demonstrating error handling for non-existent patients.

Uploaded by

forex15701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

Fast API

1 - Intro

2 - Definition

3 - HTTP Methods (HyperText transfer protocol):

1- GET - data fetch from server ( Retrieve data ) @[Link]()

2- POST - data send to a server ( Submit/create data ) @[Link]()

3- PUT - Update/replace existing data @[Link]()

4- DELETE - Delete data @[Link]()

4 - Path parameter
Path parameters are parts of the URL path. You define them by putting curly braces {} in the
path.

@[Link]("/patient/{patient_id}")

def view_patient(patient_id: str = Path(..., description="ID of the patient in the DB",


example="P001")):

# load all the patients


data = load_data()

if patient_id in data:

return data[patient_id]

raise HTTPException(status_code=404, detail="Patient not found") #function to return a error


if patient is not in DB

5 - Query Parameter
Query parameters come after the ? in the URL and are used to filter, sort, or
control the request.

You might also like