Esempio n. 1
0
def get_open_for_html():
	"""
	Returns list of dicts holding information to be used by the dynamic
	'index.html' page upon loading. Each dict in the list is formatted as
	follows:

	{
		'name': name of dining location,
		'to_close': time remaining until close formatted like '03h:12m'
		'close_time': time of close formatted like '11:00 PM',
		'style': the HTML style tag to use for these cells
	}

	"""
	return_list = []
	open_list = miami_api.get_open()

	for location in open_list:
		to_close = get_time_to_close(location['close'])
		to_close_string = get_close_string(to_close)
		close_time = format_time(location['close'])
		style = get_style(to_close)

		return_list.append({
			'name': location['name'],
			'to_close': to_close_string,
			'close_time': close_time,
			'style': style
		})

	return return_list
Esempio n. 2
0
	def get(self, filename='index.html'):
		if filename is '' or filename == 'index.html':
			open_list = html_functions.get_open_for_html()
			self.render('index.html', open_list=open_list)
			return
		if filename == 'api' or filename == 'api/' or filename == 'api.html':
			open_list = miami_api.get_open()
			url = self.request.uri
			self.render('api.html', open_list = open_list, url = url)
			return
		self.render(filename)
Esempio n. 3
0
	def get(self):
		response = miami_api.get_open()
		json_response = json.dumps(response, indent=4 * ' ')
		self.set_header('Content-Type', 'application/json')
		self.write(json_response)