Let's now create a web page that loads when the / route is accessed. Remember the api app that we created in the project? Let's make the index page a part of this app for the sake of simplicity. While it is possible to create this route in the urls.py file of the mysite app, we will provide the api app with its own route handling file.
Let's begin with the steps for setting up the home page template:
- Create a file, urls.py, inside the api folder. The complete path of this file relative to the project directory would be mysite/api/urls.py. Inside this file, let's add the / route, using the following code:
from django.urls import pathfrom . import viewsurlpatterns = [ path('', views.indexView), # This line ...