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.