...

/

Demo Application

Demo Application

Look at how TheMealDB and TheCocktailDB APIs can be used in an actual application.

Let us now look at a Django app that uses TheMealDB API and TheCocktailDB API to provide the user with some delicious recipes.

Live demo

The widget below contains the code for our application. Click the “Run” button to run the app.

"""
ASGI config for foodapp_demo project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'foodapp_demo.settings')

application = get_asgi_application()

Let's look at the code in views.py, where the API is being called. There are three functions in views.py. Let's look at what each one does and how.

  • The get_cocktails_list() function, defined in lines 8—17, is used to get the list of the cocktails available in the ...