-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
33 lines (28 loc) · 988 Bytes
/
views.py
File metadata and controls
33 lines (28 loc) · 988 Bytes
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
28
29
30
31
32
33
from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponse
from django.shortcuts import render_to_response
import datetime
def hello(request):
return HttpResponse("Hello World")
# 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()
dt=datetime.datetime.now()+datetime.timedelta(hours=offset)
# assert False
html="<html><body>In %s hour(s), it will be %s.</body></html>"%(offset,dt)
return HttpResponse(html)
# def current_datetime(request):
# now=datetime.datetime.now()
# t=get_template('current_datetime.html')
# html=t.render(Context({'current_date':now}))
# return HttpResponse(html)
def current_datetime(request):
now=datetime.datetime.now()
return render_to_response('current_datetime.html',{'current_date':now})