Question: In python and using fastAPI solve: Create a new project in PyCharm titled YOURNAME - Assignment 3 . Using Fast API. Install the FastAPI and
In python and using fastAPI solve:
Create a new project in PyCharm titled YOURNAMEAssignment Using Fast API.
Install the FastAPI and Uvicorn libraries in your project by using pip.
Create a new python file called maincontroller.py and set up your FastAPI variable.
Swagger
Modify your swagger to reflect Module # contact information, and description. The contact information should be your email and the description should say the assignment #
Global List
After you created the appFastAPI variable for our API you need to declare our global list of products. We are using a list for now as our database.
In future assignments we will be integrating a database and not be using the list.
Products Name: 'Apple', 'Price': 'Type': 'Fruit'
Name: 'Orange', 'Price': 'Type': 'Fruit'
Name: 'Tomato', 'Price': 'Type': 'Fruit'
Name: 'Cabbage', 'Price': 'Type': 'Vegetable'
Name: 'Potato', 'Price': 'Type': 'Vegetable'
Name: 'Potato', 'Price': 'Type': 'Vegetable'
Request Object
The request object will be used in the POST methods to modify or add new data. The object must contain all variables of the "Products" object from the dictionary list.
Endpoints
products
Write a function that is mapped to the following endpoint: products
Type: GET
Method Name: getproducts
Parameters: NONE
Return: Products
The above method should return a list of all products.
productsmod
Write a function that is mapped to the following endpoint: productsmod
Type: POST
Method Name: updateproduct
Parameters: product : Product the Request Object
Return: string
The above method should return "Added New Product" if the request object didn't exist in the global list or it should return "Modified Product" if the product already exists. For this you need to check if the item is already in the list. Remember that typically one field is a unique identifier or ID for an object in a listdatabase
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
