first commit
This commit is contained in:
21
app/views.py
Normal file
21
app/views.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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))
|
||||
Reference in New Issue
Block a user