Now let's create the view file of the videos application. A view is a controller that is like an API endpoint. The file is located in decentralized_videos/videos/views.py. Refer to the code file at the following GitLab link for the full code: https://gitlab.com/arjunaskykok/hands-on-blockchain-for-python-developers/blob/master/chapter_12/decentralized_videos/videos/views.py:
from django.shortcuts import render, redirectfrom videos.models import videos_sharingdef index(request): videos = videos_sharing.recent_videos() context = {'videos': videos} return render(request, 'videos/index.html', context)......def like(request): video_user = request.POST['video_user'] index = int(request.POST['index']) password = request.POST['password'] video_liker ...