예제 #1
0
파일: api.py 프로젝트: habeanf/polling2012
	def get(self):
		pollobj = Poll.get_by_id('us_state_2012')
		if not pollobj:
			logging.info('Poll does not exist')
			getpolls()
			pollobj = Poll.get_by_id('us_state_2012')
			if pollobj is None:
				raise Exception("Poll not found")
		else:
			logging.info('Poll found')

		self.response.headers['Content-Type'] = 'application/json'
		self.response.out.write(dumps(pollobj.poll))
예제 #2
0
파일: home.py 프로젝트: habeanf/polling2012
	def get(self):
		pollobj = Poll.get_by_id('us_state_2012')
		if not pollobj:
			logging.info('Poll does not exist')
			getpolls()
			pollobj = Poll.get_by_id('us_state_2012')
			if pollobj is None:
				raise Exception("Poll not found")
		else:
			logging.info('Poll found')

		template_values = {
			'data': dumps(pollobj.poll),
			'lastupdate': pollobj.updated,
			'ga_id': ga_id
		}

		template = jinja_environment.get_template('d3demo.html')

		self.response.out.write(template.render(template_values))