This repository has been archived on 2025-09-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
covid19-dashboard/app/views.py
2021-05-14 14:41:00 +05:30

21 lines
679 B
Python

from django.shortcuts import render, get_object_or_404, redirect
from django.template import loader
from django.http import HttpResponse
def index(request):
return render(request, "index.html")
def pages(request):
context = {}
# All resource paths end in .html.
# Pick out the html file name from the url. And load that template.
try:
load_template = request.path.split('/')[-1]
template = loader.get_template('pages/' + load_template)
return HttpResponse(template.render(context, request))
except:
template = loader.get_template( 'pages/error-404.html' )
return HttpResponse(template.render(context, request))