Activity 21: Python Anywhere Deployment
Step-by-Step Guide for Deploying on PythonAnywhere
Follow these steps to successfully deploy the project on PythonAnywhere:
Step 1: Fork the GitHub Repository
Go to the GitHub repository and click the Fork button at the top-right of the page.
Fork the repository to your own GitHub account.
Step 2: Set Up a PythonAnywhere Account
Sign up for an account at PythonAnywhere.
After registering, make sure to note down your login credentials (username and password) for future reference. It’s recommended to store this information securely in an Excel file or password manager.
Step 3: Add New Bash Consoles in the Console Tab
Once logged in to your PythonAnywhere account, go to the Consoles tab.
Click on Start a new console, and select Bash to open a Bash console. You will use this for all terminal commands.
Step 4: Clone the Repository to the Server
In the Bash console, clone your forked repository using the following command:
git clone https://github.com/your-username/keriderya-api.git
Replace
your-username
with your actual GitHub username.
Step 5: Set Up a MySQL Database in the MySQL Console
Navigate to the Databases tab in PythonAnywhere.
Click Create a new database.
Name your database (e.g.,
keriderya_db
) and create it.Make a note of the database name, username, and password, as you’ll need these for configuration.
Step 6: Create a Virtual Environment
In the Bash console, navigate to the directory where you cloned the repository:
cd keriderya-api
Create a virtual environment using the following command:
python -m venv venv
Step 7: Activate the Virtual Environment
Activate the virtual environment with this command:
source venv/bin/activate
Install requirements
pip install -r requirements.txt
Step 8: Configure the Environment Variables
Create a
.env
file in the root of your project and add the necessary environment variables such as database credentials and other configuration details.Example:
nano .env
Step 9: Edit config.py
and Remove the Certificate
Open
config.py
usingnano
editor:nano config.py
Look for any SSL certificate or configuration references and remove them, as they may not be needed on PythonAnywhere’s default configuration.
import os from dotenv import load_dotenv # Load environment variables from .env load_dotenv() class Config: API_TITLE = "RESTAURANT API" API_VERSION = "v1" OPENAPI_VERSION = "3.0.3" SECRET_KEY = os.getenv('SECRET_KEY') SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL') SQLALCHEMY_TRACK_MODIFICATIONS = False FLASK_ENV = os.getenv('FLASK_ENV', 'development') # SSL settings passed as 'connect_args'
Step 10: Run Flask DB Upgrade
Run the following Flask command to apply database migrations:
python -m flask db upgrade
Step 11: Check MySQL Tables
Check that the database tables were created successfully by entering the MySQL console:
Enter your MySQL password when prompted, and then check the tables:
SHOW TABLES;
Step 12: Go to the Web Tab
- In your PythonAnywhere dashboard, go to the Web tab.
Step 13: Create a New Web App
Click Add a new web app.
Choose Flask for the web framework.
Select Python 3.10 for the Python version.
Step 14: Path Virtual Environment
Under the Virtualenv section, enter the path to your virtual environment (for example,
/home/your-username/keriderya-api/venv
).This will ensure that PythonAnywhere uses your virtual environment for the web app.
/home/Jovie123/keriderya-api/venv
Step 15: Edit WSGI File
In the Web tab, scroll down to the WSGI configuration file section and click the link to open the WSGI configuration file.
Edit the file to include the correct paths to your Flask app and virtual environment. Example WSGI setup:
```python import os import sys from dotenv import load_dotenv
project_home = '/home/Jovie123/keriderya-api' if project_home not in sys.path: sys.path = [project_home] + sys.path
project_folder = os.path.expanduser('~/keriderya-api') load_dotenv(os.path.join(project_folder, '.env'))
from app import create_app
app = create_app()
application = app
3. Make sure to point the `app` variable to the actual Flask application object in your code (usually in `app.py`).
---
### **Step 16: Reload the Web App**
1. After editing the WSGI file, go back to the **Web** tab and click **Reload** to apply the changes.
![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732698889966/018aa92c-7d7c-4f39-9232-3d5c228ce06f.png align="center")
---
### **Step 17: Test the Web App Using Postman**
![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732700023134/c83ed878-21b8-40a2-97f7-88f43806c0c2.png align="center")
---
### **Step 18: Add Dummy Data**
#### **Postman Testing**
1. **Create User in Postman**:
* Open Postman and create a new `POST` request.
* Set the URL to `http://127.0.0.1:5000/users`.
* In the "Body" tab, select **raw** and choose **JSON** as the format.
* Add the user data (similar to the example above) and send the request.
* If successful, you should get a response with the created user’s data, including their ID.
**Copy**
```json
{
"username": "jovramonroncal",
"email": "jovramon@gmail.com",
"password": "ramonjov123",
"role": "user"
}
Get User by UID in Postman:
Create a new
GET
request.Set the URL to
https://jovie123.pythonanywhere.com/users/user_uid
(or another UID you want to query).Send the request and verify that you get the user details for the given UID.
Get All Users (GET Request)
Step 1: Create a new GET request in Postman.
Step 2: Set the URL to
https://jovie123.pythonanywhere.com/users
to retrieve a list of all users.Step 3: Click
Send
.Step 4: The response will contain a list of all users:
Update User (PUT Request)
Step 1: Create a new PUT request in Postman.
Step 2: Set the URL to
https://jovie123.pythonanywhere.com/users/{user_uid}
, replacing{user_uid}
with the user’s UID you want to update. For example:https://jovie123.pythonanywhere.com/users/2f5763b1-5539-4ef2-9e56-53c5d00759e5
Step 3: In the "Body" tab, select
raw
and chooseJSON
as the format.Step 4: Add the updated user data. For example, to change the user's name:
Copy
{ "username": "roncal", "email": "roncal_jov@gmail.com", "password": "ramonjov123", "role": "user" }
Step 5: Click
Send
to send the PUT request.Step 6: If successful, the response will contain the updated user data:
Delete User (DELETE Request)
Step 1: Create a new DELETE request in Postman.
Step 2: Set the URL to
https://jovie123.pythonanywhere.com/users/{user_uid
}
, replacing{user_uid}
with the UID of the user you want to delete. For example:https://jovie123.pythonanywhere.com/users/2f5763b1-5539-4ef2-9e56-53c5d00759e5
.Step 3: Click
Send
to delete the user.
Result
1. Create Restaurant Category (POST Request)
Step 1: Open Postman and Create a New POST Request
Open Postman and create a new request.
Choose POST as the HTTP method.
Set the URL to:
https://jovie123.pythonanywhere.com/restaurant-category
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the category data in JSON format. For example:
Copy
{ "name": "Buffet" }
Step 3: Send the Request
- Click Send to create the restaurant category.
Step 4: Verify the Response
If the request is successful, you should receive a response with the created restaurant category’s data, including an ID. For example:
{ "category_id": 1, "category_uuid": "4a992462-934b-411f-83bd-3d4bcecd1bca", "created_at": "2024-11-27T11:57:23", "deleted_at": null, "name": "Buffet", "updated_at": "2024-11-27T11:57:23" }
2. Get Restaurant Category by UID (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/{category_uid}
Replace{category_id}
with the ID of the category you want to query (e.g.,1
).Example URL:
https://jovie123.pythonanywhere.com/restaurant-category/db69624d-665b-4a26-b50d-b9376785a82e
Step 2: Send the Request
- Click Send to get the details of the specified restaurant category.
Step 3: Verify the Response
If the category exists, the response should contain the category data, such as:
3. Get All Restaurant Categories (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/restaurant-category
Step 2: Send the Request
- Click Send to retrieve a list of all restaurant categories.
Step 3: Verify the Response
The response will contain a list of all restaurant categories. For example:
[ { "category_id": 1, "category_uuid": "4a992462-934b-411f-83bd-3d4bcecd1bca", "created_at": "2024-11-27T11:57:23", "deleted_at": null, "name": "Buffet", "updated_at": "2024-11-27T11:57:23" }, { "category_id": 2, "category_uuid": "db69624d-665b-4a26-b50d-b9376785a82e", "created_at": "2024-11-27T11:58:36", "deleted_at": null, "name": "Cafe", "updated_at": "2024-11-27T11:58:36" }, { "category_id": 3, "category_uuid": "247eae24-bc28-4efd-8eaa-23fbbabaaceb", "created_at": "2024-11-27T11:58:46", "deleted_at": null, "name": "Fast food", "updated_at": "2024-11-27T11:58:46" }, { "category_id": 4, "category_uuid": "5a3d4c4c-36ee-431e-8926-1e8c077d0fd8", "created_at": "2024-11-27T11:59:06", "deleted_at": null, "name": "Diner", "updated_at": "2024-11-27T11:59:06" } ]
4. Update Restaurant Category (PUT Request)
Step 1: Create a New PUT Request
Create a new PUT request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/restaurant-category/{category_uid}
Replace{category_uid}
with the category ID you want to update .Example URL:
https://jovie123.pythonanywhere.com/restaurant-category/db69624d-665b-4a26-b50d-b9376785a82e
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the updated category data. For example, to update the category's name:
{ "name": "Pub" }
Step 3: Send the Request
- Click Send to send the PUT request.
Step 4: Verify the Response
If the request is successful, the response will contain the updated category data, such as:
{ "category_id": 2, "category_uuid": "db69624d-665b-4a26-b50d-b9376785a82e", "created_at": "2024-11-27T11:58:36", "deleted_at": null, "name": "Pub", "updated_at": "2024-11-27T12:02:39" }
5. Delete Restaurant Category (DELETE Request)
Step 1: Create a New DELETE Request
Create a new DELETE request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/restaurant-category/{category_uid}
Replace{category_uid}
with the category ID you want to delete (e.g.,1
).Example URL:
https://jovie123.pythonanywhere.com/restaurant-category/db69624d-665b-4a26-b50d-b9376785a82e
Step 2: Send the Request
- Click Send to delete the restaurant category.
Step 3: Verify the Response
RESULT
1. Create Restaurant (POST Request)
Step 1: Open Postman and Create a New POST Request
Open Postman and create a new request.
Choose POST as the HTTP method.
Set the URL to:
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the restaurant data in JSON format. For example:
{ "name": "Grand Buffet", "address": "789 Feast Blvd, Midtown City", "phone": "+1 (555) 555-1234", "email": "info@grandbuffet.com", "status": "true", "description": "Grand Buffet offers a wide variety of all-you-can-eat options, from salads and soups to main courses and desserts, perfect for satisfying large appetites.", "user_id": "2", "category_id": "1" }
category_uid
refers to the UID of the restaurant category (e.g., Italian, Mexican) that the restaurant belongs to.
Step 3: Send the Request
- Click Send to create the restaurant.
Step 4: Verify the Response
If the request is successful, you should receive a response with the created restaurant’s data, including an ID. For example:
{ "address": "789 Feast Blvd, Midtown City", "category_id": 1, "created_at": "2024-11-27T12:07:05", "deleted_at": null, "description": "Grand Buffet offers a wide variety of all-you-can-eat options, from salads and soups to main courses and desserts, perfect for satisfying large appetites.", "email": "info@grandbuffet.com", "name": "Grand Buffet", "phone": "+1 (555) 555-1234", "restaurant_id": 2, "restaurant_uuid": "869eae65-c470-4e35-a4b3-6cd7751e885d", "status": true, "updated_at": "2024-11-27T12:07:05", "user_id": 2 }
2. Get Restaurant by ID (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/restaurant/{restaurant_uid}
Replace{restaurant_uid}
with the ID of the restaurant you want to queryExample URL:
https://jovie123.pythonanywhere.com/restaurant/fa09aa65-a09a-4353-a74c-035ba13357ef
Step 2: Send the Request
- Click Send to get the details of the specified restaurant.
Step 3: Verify the Response
If the restaurant exists, the response should contain the restaurant data, such as:
{ "address": "456 Retro St, Uptown City", "category_id": 2, "created_at": "2024-11-27T12:08:27", "deleted_at": null, "description": "Classic Diner is a nostalgic American diner where you can enjoy hearty meals like burgers, fries, and milkshakes, all served in a retro setting.", "email": "contact@classicdiner.com", "name": "Classic Diner", "phone": "+1 (555) 987-6543", "restaurant_id": 3, "restaurant_uuid": "fa09aa65-a09a-4353-a74c-035ba13357ef", "status": true, "updated_at": "2024-11-27T12:08:27", "user_id": 3 }
3. Get All Restaurants (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
http://127.0.0.1:5000/restaurant
Step 2: Send the Request
- Click Send to retrieve a list of all restaurants.
Step 3: Verify the Response
The response will contain a list of all restaurants. For example:
[ { "address": "123 Morning Ave, Downtown City", "category_id": 1, "created_at": "2024-11-27T12:06:02", "deleted_at": null, "description": "Sunrise Café is a cozy and inviting spot where locals come to enjoy freshly brewed coffee, homemade pastries, and a warm atmosphere.", "email": "info@sunrisecafe.com", "name": "Sunrise Café", "phone": "+1 (555) 123-4567", "restaurant_id": 1, "restaurant_uuid": "18f0aff0-3b2a-48e1-807c-58ad9cebdf1a", "status": true, "updated_at": "2024-11-27T12:06:02", "user_id": 2 }, { "address": "789 Feast Blvd, Midtown City", "category_id": 1, "created_at": "2024-11-27T12:07:05", "deleted_at": null, "description": "Grand Buffet offers a wide variety of all-you-can-eat options, from salads and soups to main courses and desserts, perfect for satisfying large appetites.", "email": "info@grandbuffet.com", "name": "Grand Buffet", "phone": "+1 (555) 555-1234", "restaurant_id": 2, "restaurant_uuid": "869eae65-c470-4e35-a4b3-6cd7751e885d", "status": true, "updated_at": "2024-11-27T12:07:05", "user_id": 2 }, { "address": "456 Retro St, Uptown City", "category_id": 2, "created_at": "2024-11-27T12:08:27", "deleted_at": null, "description": "Classic Diner is a nostalgic American diner where you can enjoy hearty meals like burgers, fries, and milkshakes, all served in a retro setting.", "email": "contact@classicdiner.com", "name": "Classic Diner", "phone": "+1 (555) 987-6543", "restaurant_id": 3, "restaurant_uuid": "fa09aa65-a09a-4353-a74c-035ba13357ef", "status": true, "updated_at": "2024-11-27T12:08:27", "user_id": 3 } ]
4. Update Restaurant (PUT Request)
Step 1: Create a New PUT Request
Create a new PUT request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/restaurant/{restaurant_uid}
Replace{restaurant_uid}
with the ID of the restaurant you want to update.Example URL:
https://jovie123.pythonanywhere.com/restaurant/fa09aa65-a09a-4353-a74c-035ba13357ef
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the updated restaurant data. For example, to change the restaurant's name and rating:
{ "name": "Jov's Pizza", "address": "789 Pizza Lane, Westside District", "phone": "8 7000", "email": "info@bellaitaliapizza.com", "status": "true", "description": "Jov's pizza offers authentic Italian pizza made with fresh, high-quality ingredients.", "user_id": "2", "category_id": "3" }
Step 3: Send the Request
- Click Send to send the PUT request.
Step 4: Verify the Response
If the request is successful, the response will contain the updated restaurant data, such as:
Copy
{ "address": "789 Pizza Lane, Westside District", "category_id": 3, "created_at": "2024-11-27T12:08:27", "deleted_at": null, "description": "Jov's pizza offers authentic Italian pizza made with fresh, high-quality ingredients.", "email": "info@bellaitaliapizza.com", "name": "Jov's Pizza", "phone": "8 7000", "restaurant_id": 3, "restaurant_uuid": "fa09aa65-a09a-4353-a74c-035ba13357ef", "status": true, "updated_at": "2024-11-27T12:12:04", "user_id": 2 }
5. Delete Restaurant (DELETE Request)
Step 1: Create a New DELETE Request
Create a new DELETE request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/restaurant/{restaurant_uid}
Replace{restaurant_uid}
with the ID of the restaurant you want to delete .Example URL:
https://jovie123.pythonanywhere.com/restaurant/fa09aa65-a09a-4353-a74c-035ba13357ef
Step 2: Send the Request
- Click Send to delete the restaurant.
Step 3: Verify the Response
RESULT
1. Create Menu Category (POST Request)
Step 1: Open Postman and Create a New POST Request
Open Postman and create a new request.
Choose POST as the HTTP method.
Set the URL to:
https://jovie123.pythonanywhere.com/menu-category
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the menu category data in JSON format. For example:
{ "name": "Breakfast" }
name
: The name of the menu category (e.g., Appetizers, Desserts, etc.).
Step 3: Send the Request
- Click Send to create the menu category.
Step 4: Verify the Response
If the request is successful, you should receive a response with the created menu category’s data, including an ID. For example:
{ "created_at": "2024-11-27T12:16:50", "deleted_at": null, "menu_id": 1, "menu_uuid": "cb371f8a-6746-4170-ae59-47e8702ec86f", "name": "Breakfast", "updated_at": "2024-11-27T12:16:50" }
2. Get Menu Category by ID (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu-category/{category_uid}
Replace{category_uid}
with the ID of the menu category you want to query .Example URL:
https://jovie123.pythonanywhere.com/menu-category/cb371f8a-6746-4170-ae59-47e8702ec86f
Step 2: Send the Request
- Click Send to get the details of the specified menu category.
Step 3: Verify the Response
- If the category exists, the response should contain the category data, such as:
3. Get All Menu Categories (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu-category
Step 2: Send the Request
- Click Send to retrieve a list of all menu categories.
Step 3: Verify the Response
The response will contain a list of all menu categories. For example:
[ { "created_at": "2024-11-27T12:16:50", "deleted_at": null, "menu_id": 1, "menu_uuid": "cb371f8a-6746-4170-ae59-47e8702ec86f", "name": "Breakfast", "updated_at": "2024-11-27T12:16:50" }, { "created_at": "2024-11-27T12:17:22", "deleted_at": null, "menu_id": 2, "menu_uuid": "ddd8e49b-2457-4d67-b053-32d43e0a9fb7", "name": "Desserts", "updated_at": "2024-11-27T12:17:22" }, { "created_at": "2024-11-27T12:17:35", "deleted_at": null, "menu_id": 3, "menu_uuid": "b1fc6545-d6c8-4e08-94b9-dbc8890b5b39", "name": "blank", "updated_at": "2024-11-27T12:17:35" } ]
4. Update Menu Category (PUT Request)
Step 1: Create a New PUT Request
Create a new PUT request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu-category/{category_uid}
Replace{category_uid}
with the ID of the menu category you want to update.Example URL:
https://jovie123.pythonanywhere.com/menu-category/b1fc6545-d6c8-4e08-94b9-dbc8890b5b39
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the updated menu category data. For example, to change the category's name and description:
{ "name": "drinks" }
Step 3: Send the Request
- Click Send to send the PUT request.
Step 4: Verify the Response
If the request is successful, the response will contain the updated menu category data, such as:
{ "created_at": "2024-11-27T12:17:35", "deleted_at": null, "menu_id": 3, "menu_uuid": "b1fc6545-d6c8-4e08-94b9-dbc8890b5b39", "name": "drinks", "updated_at": "2024-11-27T12:20:17" }
5. Delete Menu Category (DELETE Request)
Step 1: Create a New DELETE Request
Create a new DELETE request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu-category/{category_uid}
Replace{category_uid}
with the ID of the menu category you want to delete .Example URL:
https://jovie123.pythonanywhere.com/menu-category/b1fc6545-d6c8-4e08-94b9-dbc8890b5b39
Step 2: Send the Request
- Click Send to delete the menu category.
Step 3: Verify the Response
RESULT:
1. Create Menu (POST Request)
Step 1: Open Postman and Create a New POST Request
Open Postman and create a new request.
Choose POST as the HTTP method.
Set the URL to:
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the menu data in JSON format. For example:
{ "name": "Salad Bar", "description": "A variety of fresh vegetables, toppings, and dressings for creating your own custom salad.", "price": "399", "restaurant_id": "1", "category_id": "1", "availability": "true" }
Step 3: Send the Request
- Click Send to create the menu item.
Step 4: Verify the Response
If the request is successful, you should receive a response with the created menu item’s data, including an ID. For example:
{ "availability": true, "category_id": 1, "created_at": "2024-11-27T12:24:57", "deleted_at": null, "description": "A variety of fresh vegetables, toppings, and dressings for creating your own custom salad.", "menu_id": 1, "menu_uuid": "e96b79ca-f442-449c-ac40-39fcefe41631", "name": "Salad Bar", "price": 399, "restaurant_id": 1, "updated_at": "2024-11-27T12:24:57" }
2. Get Menu by UID (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu/{menu_uid}
Replace{menu_uid}
with the ID of the menu item you want to query .Example URL:
https://jovie123.pythonanywhere.com/menu/bd937274-c08e-497a-94b6-5e84b3c98625
Step 2: Send the Request
- Click Send to get the details of the specified menu item.
Step 3: Verify the Response
If the menu item exists, the response should contain the menu item data, such as:
3. Get All Menus (GET Request)
Step 1: Create a New GET Request
Create a new GET request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu
Step 2: Send the Request
- Click Send to retrieve a list of all menu items.
Step 3: Verify the Response
The response will contain a list of all menu items. For example:
[ { "availability": true, "category_id": 1, "created_at": "2024-11-27T12:24:57", "deleted_at": null, "description": "A variety of fresh vegetables, toppings, and dressings for creating your own custom salad.", "menu_id": 1, "menu_uuid": "e96b79ca-f442-449c-ac40-39fcefe41631", "name": "Salad Bar", "price": 399, "restaurant_id": 1, "updated_at": "2024-11-27T12:24:57" }, { "availability": true, "category_id": 1, "created_at": "2024-11-27T12:26:22", "deleted_at": null, "description": "Two eggs any style, crispy bacon, hash browns, and toast.", "menu_id": 2, "menu_uuid": "f5a0e2ea-def6-46c3-8acb-019caf2adb9a", "name": "Classic Breakfast Plate", "price": 299, "restaurant_id": 2, "updated_at": "2024-11-27T12:26:22" }, { "availability": true, "category_id": 2, "created_at": "2024-11-27T12:26:56", "deleted_at": null, "description": "Perfectly seared scallops with a citrus glaze and a side of microgreens.", "menu_id": 3, "menu_uuid": "bd937274-c08e-497a-94b6-5e84b3c98625", "name": "Seared Scallops", "price": 799, "restaurant_id": 2, "updated_at": "2024-11-27T12:26:56" } ]
4. Update Menu (PUT Request)
Step 1: Create a New PUT Request
Create a new PUT request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu/{menu_uid}
Replace{menu_uid}
with the ID of the menu item you want to update .Example URL:
https://jovie123.pythonanywhere.com/menu/f5a0e2ea-def6-46c3-8acb-019caf2adb9a
Step 2: Set the Request Body
Go to the Body tab.
Select raw and choose JSON from the dropdown.
Add the updated menu item data. For example, to change the menu item’s price and description:
{ "name": "Breakfast", "description": "Two eggs any style, crispy bacon, hash browns, and toast.", "price": "299", "restaurant_id": "1", "category_id": "1", "availability": "false" }
Step 3: Send the Request
- Click Send to send the PUT request.
Step 4: Verify the Response
If the request is successful, the response will contain the updated menu item data, such as:
5. Delete Menu (DELETE Request)
Step 1: Create a New DELETE Request
Create a new DELETE request in Postman.
Set the URL to:
https://jovie123.pythonanywhere.com/menu/{menu_uid}
Replace{menu_uid}
with the ID of the menu item you want to delete .Example URL:
https://jovie123.pythonanywhere.com/menu/f5a0e2ea-def6-46c3-8acb-019caf2adb9a
Step 2: Send the Request
- Click Send to delete the menu item.
Step 3: Verify the Response
RESULT: