July 2019
Beginner to intermediate
302 pages
9h 38m
English
In the beginning, the database is empty and has no products. This can be confirmed by opening http://127.0.0.1:5000/products in a browser. This would result in a 404 NOT FOUND error page.
Now, first we would want to create a product. For this, we need to send a POST request, which can easily be sent from the Python prompt using the requests library:
>>> import requests
>>> requests.post('http://127.0.0.1:5000/product-create', data={'name': 'iPhone 5S', 'price': '549.0'})
To confirm whether the product is now in the database, we can open http://127.0.0.1:5000/products in the browser again. This time, it would show a JSON dump of the product details. ...