Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
The 'meal_detail' variable should be defined inside the 'main()' function because it's a local variable that's used within that function.
  • Loading branch information
RishavRaj20 authored Jan 11, 2024
1 parent 25776b5 commit 4c49435
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions projects/what-for-dinner/main.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
import requests # Import the 'requests' library for making HTTP requests.

import requests # Import the 'requests' library for making HTTP requests.

def main():
r = requests.get(
menu_detail = dict(requests.get(
"http://themealdb.com/api/json/v1/1/random.php"
) # Fetch a random meal data from the API.
meal_detail = dict(r.json())["meals"][
).json())["meals"][
0
] # Extract the details of the first meal from the API response.
] # Extract the details of the first meal from the API response.

# TODO: Get information from the menu
menu_name = meal_detail[
menu_name = menu_detail[
"strMeal"
] # Extract the name of the meal from the meal detail.
menu_category = meal_detail[
] # Extract the name of the meal from the meal detail.
menu_category = menu_detail[
"strCategory"
] # Extract the category of the meal from the meal detail.
menu_tags = meal_detail[
] # Extract the category of the meal from the meal detail.
menu_tags = menu_detail[
"strTags"
] # Extract the tags (if available) of the meal from the meal detail.
menu_country = meal_detail[
] # Extract the tags (if available) of the meal from the meal detail.
menu_country = menu_detail[
"strArea"
] # Extract the country of the meal from the meal detail.
menu_instruction = meal_detail[
] # Extract the country of the meal from the meal detail.
menu_instruction = menu_detail[
"strInstructions"
] # Extract the cooking instructions of the meal.
menu_video = meal_detail[
] # Extract the cooking instructions of the meal.
menu_video = menu_detail[
"strYoutube"
] # Extract the YouTube video link for the meal (if available).
] # Extract the YouTube video link for the meal (if available).

# TODO: Define color codes for printing colored output.
class bcolors:
Expand All @@ -52,4 +50,4 @@ class bcolors:


if __name__ == "__main__":
main() # Call the main function when the script is executed as the main program.
main() # Call the main function when the script is executed as the main program.

0 comments on commit 4c49435

Please sign in to comment.