2015-05-24 13:56:43 +02:00
|
|
|
import os
|
2015-05-24 13:10:47 +02:00
|
|
|
from django.shortcuts import render
|
2015-05-25 20:57:28 +02:00
|
|
|
from django.conf import settings
|
2016-02-29 16:19:42 +01:00
|
|
|
from django.http import HttpResponse
|
2015-05-24 13:10:47 +02:00
|
|
|
|
2015-05-29 17:14:34 +02:00
|
|
|
from . import database
|
2015-05-25 16:12:22 +02:00
|
|
|
from .models import PageView
|
|
|
|
|
2015-05-24 13:10:47 +02:00
|
|
|
# Create your views here.
|
|
|
|
|
|
|
|
def index(request):
|
2020-09-30 14:09:09 +02:00
|
|
|
"""Takes an request object as a parameter and creates an pageview object then responds by rendering the index view."""
|
2015-05-25 16:12:22 +02:00
|
|
|
hostname = os.getenv('HOSTNAME', 'unknown')
|
|
|
|
PageView.objects.create(hostname=hostname)
|
2015-05-25 20:57:28 +02:00
|
|
|
|
2015-05-29 12:23:59 +02:00
|
|
|
return render(request, 'welcome/index.html', {
|
2015-05-25 20:54:23 +02:00
|
|
|
'hostname': hostname,
|
2015-05-29 17:14:34 +02:00
|
|
|
'database': database.info(),
|
2015-05-25 16:12:22 +02:00
|
|
|
'count': PageView.objects.count()
|
|
|
|
})
|
2016-02-29 16:19:42 +01:00
|
|
|
|
|
|
|
def health(request):
|
2020-09-30 14:09:09 +02:00
|
|
|
"""Takes an request as a parameter and gives the count of pageview objects as reponse"""
|
2016-02-29 16:19:42 +01:00
|
|
|
return HttpResponse(PageView.objects.count())
|