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 YOURNAME-Assignment3. Using Fast API.
Install the FastAPI and Uvicorn libraries in your project by using pip.
Create a new python file called main_controller.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 app=FastAPI() 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': 4.99, 'Type': 'Fruit'},
{'Name': 'Orange', 'Price': 8.99, 'Type': 'Fruit'},
{'Name': 'Tomato', 'Price': 3.99, 'Type': 'Fruit'},
{'Name': 'Cabbage', 'Price': 1.99, 'Type': 'Vegetable'},
{'Name': 'Potato', 'Price': 2.50, 'Type': 'Vegetable'},
{'Name': 'Potato', 'Price': 2.50, '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: get_products
Parameters: NONE
Return: Products[]
The above method should return a list of all products.
/products/mod
Write a function that is mapped to the following endpoint: "/products/mod"
Type: POST
Method Name: update_product
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 list/database.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!