This repository contains code for a Flask Cupcakes Exercise, on building a JSON API, perform testing using Insomnia, write integration tests, and create a simple HTML/JS frontend.
-
Create a virtual environment and install dependencies: python -m venv venv source venv/bin/activate pip install -r requirements.txt
-
Initialize a Git repository: git init
° Create the Cupcake model in models.py. ° Set up a cupcakes database. ° Run seed.py to add sample cupcakes.
° Implement routes: ° GET /api/cupcakes: Get all cupcakes. ° GET /api/cupcakes/: Get a single cupcake. ° POST /api/cupcakes: Create a cupcake. ° Test using Insomnia. ° Run provided tests: python -m unittest -v tests
° Implement routes: ° PATCH /api/cupcakes/: Update a cupcake. ° DELETE /api/cupcakes/: Delete a cupcake. ° Test using Insomnia.
° Add tests for the PATCH and DELETE routes.
° Implement the GET /: route to return an HTML page. ° Use JavaScript (axios and jQuery) to: ° Query the API to get cupcakes and add them to the page. ° Handle form submission to inform the API about a new cupcake and update the page's cupcake list.
- Start the Flask application: flask run
- Access the application in your browser at http://localhost:5000.
° Make sure your virtual environment is activated before running any commands. ° Inspect the browser console for any JavaScript errors. ° Ensure the Flask server is running when accessing the frontend. ° Refer to the provided code and comments for detailed explanations.