Question: solve this in python. tnx | Task 4 . Definirajte aiohttp poslu itelj koji radi na portu 8 0 8 1 . Poslu itelj mora
solve this in python. tnx Task Definirajte aiohttp posluitelj koji radi na portu Posluitelj mora imati dvije rute: proizvodi i proizvodiid Prva ruta vraa listu proizvoda u JSON formatu, a druga rutu vraa tono jedan proizvod prema IDu Ako proizvod s traenim IDem ne postoji, vratite odgovor s statusom i porukom error: 'Proizvod s traenim IDem ne postoji'
Proizvode pohranite u listu rjenika:
proizvodi
id: "naziv": "Laptop", "cijena":
id: "naziv": "Mis "cijena":
id: "naziv": "Tipkovnica", "cijena":
id: "naziv": "Monitor", "cijena":
id: "naziv": "slusalice "cijena":
J
within the main coroutine of the same script.
Test the server for all cases through a client session
Task Upgrade the server from the previous task to also support the POST method on the orders path.
This route receives JSON data about a new order in the following format. To begin, imagine that each order is simple and contains only one product and the quantity ordered:
"proizvodid:
"kolicina":
The handler coroutine of this method must check if the product with the requested ID exists within the products list If it does not exist, return a response with status and message error: 'Product with requested ID does not
exist' If the product exists, add a new order to the orders list and return a response with the completed orders list in JSON format and the appropriate status code.
Define the orders list globally, as an empty list.
Your final server must contain routes: productsproductsid and orders
Test the server for all cases through a client session within the main coroutine of the same script.
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
