Django Meme App

django-admin startproject MEME
cd MEME
python manage.py startapp mymeme
Project structure
In the installed app list of settings.py of the project add ‘mymeme’ app and in the DIRS[] add ‘templates’
from django.contrib import adminfrom django.urls import path,includeurlpatterns = [path('admin/', admin.site.urls),path('',include('mymeme.urls'))]
from django.urls import path,includefrom . import viewsurlpatterns = [path('',views.getdata,name="getdata")]
from django.shortcuts import renderimport requests# Create your views here.def getdata(request):        response=requests.get('https://meme-api.herokuapp.com/gimme').json()        context={              'url':response['url']        }        return render(request,'index.html',context)
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Meme App</title><style>.container{display: flex;justify-content: center;}</style></head><body><div class="container"><img src="{{ url }}" alt="Your internet connection may be broken!" style="width: 30%;height:30%;padding:15px;"></div><div class="container"><button style="background-color: aqua;padding:10px;margin:15px;border-radius:5px;cursor:pointer;" onclick="location.href='{% url 'getdata' %}'">Press To Load More</button></div></body></html>
Result

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store