from django.template import Template, Context from django.http import HttpResponse import datetime from django.template import Context, loader from django.http import HttpResponse #def current_datetime(request) : # now = datetime.datetime.now() # html = " It is now %s " % now # return HttpResponse(html) def hours_offset(request, plus_or_minus,offset) : offset = int(offset) if plus_or_minus == 'plus': dt = datetime.datetime.now() + datetime.timedelta(hours=offset) html = " In %s hours it will be %s. " %(offset,dt) else: dt = datetime.datetime.now() - datetime.timedelta(hours=offset) html = " %s hours ago it was %s. " %(offset,dt) return HttpResponse(html) def hello(request) : return HttpResponse("Hallo Aditi") def current_datetime(request): now = datetime.datetime.now() t = Template("It is now {{ current_date }}.") html = t.render(Context({'current_date' : now})) return HttpResponse(html) def temp(request): t = loader.get_template('hello.html'); c = Context({ 'dir':'hello' , 'name':'Aditi' }) return HttpResponse(t.render(c)) def order(request): t = loader.get_template('order.html'); c = Context({ 'person_name': 'John' ... #'product': 'SuperLawnMower', ... #'company': 'Outdoor Equipment', ... #'ship_date': datetime.date(2009, 4, 2), ... #'ordered_warranty': True }) return HttpResponse(t.render(c))