PYTHON CODE (DATABASE) #flask_SQLAchemy using: db.session.add() and db.session.delete (add): Implement a database code that allows the user to enter the name of a fruit. This fruit should be saved in a list of favorites. If it’s already on the list, nothing should happen. (delete):Now the user will be allowed to enter a name of a fruit. This fruit should be deleted from the list of favorites. If it’s not on the list, nothing should happen. (output): The ouput page should return the statement “You have X saved fruits”, where X is the number of fruit the user has saved, as well as a list of the saved fruits. The number should increment when a new fruit is entered, and decrement when a fruit is deleted.
PYTHON CODE (
using: db.session.add() and db.session.delete
(add): Implement a database code that allows the user to enter the name of a fruit. This fruit should be saved in a list of favorites. If it’s already on the list, nothing should happen.
(delete):Now the user will be allowed to enter a name of a fruit. This fruit should be deleted from the list of favorites. If it’s not on the list, nothing should happen.
(output): The ouput page should return the statement “You have X saved fruits”, where X is the number of fruit the user has saved, as well as a list of the saved fruits. The number should increment when a new fruit is entered, and decrement when a fruit is deleted.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps