-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
28 lines (23 loc) · 807 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from django.http import Http404, HttpResponse
import datetime
def hello(request):
return HttpResponse("Hello wolrd")
def current_datetime(request):
now = datetime.datetime.now()
html = "<html><body>It is now %s.</body></html>" % now
return HttpResponse(html)
def hours_ahead(request,offset):
try:
offset = int(offset)
except ValueError:
raise Http404()
later = datetime.datetime.now() + datetime.timedelta(hours=offset)
html = "<html><body>Soon it will be %s.</body></html>" % later
return HttpResponse(html)
def display_meta(request):
values = request.META.items()
values.sort()
html = []
for k, v in values:
html.append('<tr><td>%s</td><td>%s</td></tr>' % (k, v))
return HttpResponse('<table>%s</table>' % '\n'.join(html))