import webapp2
from datetime import date

from models.redirect.RedirectInfo import *
from views import View


class RedirectMainHandler(webapp2.RequestHandler):
	def get(self):
		self.render_results()

	
	def render_results(self):
		view = View(response = self.response, templateName = 'redirect/info.html')
		redirectInfo = RedirectInfo()
		record = redirectInfo.GetLatest()
		
		if record is not None:
			template_values = {
				'ip' : record.ip,
				'updated_on' : record.last_updated.strftime('%Y-%m-%d %H:%M:%S')
			}
			view.Render(template_values)
			
		else:
			view.Render()
		