예제 #1
0
def state_request():
	# If this is a preflight request, then just return (runs after_request only)
	if request.method == 'OPTIONS':
		return

	table = TableState.table_by_id(request.json["table_id"])
	try:
		game_state = handle_state_request(request.json, table.key)
	# Where do the exception classes live?
	except:
		game_state = 0

	# Set correct content type.
	response.content_type = "application/json"

	return game_state
예제 #2
0
def game_request():

	# If this is a preflight request, then just return (runs after_request only)
	if request.method == 'OPTIONS':
		return

	# Query for the correct table.
	table = TableState.table_by_id(request.json["table_id"])
	try:
		response_status = handle_game_request(request.json, table.key)
	# Where do the exception classes live?
	except:	
		response_status = "423 Locked"

	# Set the correct response status and content type.
	response.status = response_status
	response.content_type = "text/html"

	# TODO? No JSON is returned with this request.
	return
예제 #3
0
def handle_game_request(game_req, table_key):
	table = TableState.table_by_id(game_req["table_id"], table_key)
	table = table_key.get()
	return handler_dict[game_req["request"]["type"]](table, game_req)