Fakultas Ilmu Komputer UI

views.py 635 Bytes
Newer Older
Samuel Dimas's avatar
Samuel Dimas committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from django.shortcuts import render, get_object_or_404, redirect
from django.template import loader
from django.http import HttpResponse, JsonResponse, HttpResponseRedirect

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(load_template)
        return HttpResponse(template.render(context, request))

    except:

        template = loader.get_template('error-404.html')
        return HttpResponse(template.render(context, request))