def get(self): """Renders the main page. When this page is shown, we create a new channel to push asynchronous updates to the client.""" player = users.get_current_user() game = None if player: game_key = player.user_id() game = Game(key_name = game_key, playerA = player, move_state = Game.MOVE_STATE_NOT_STARTED, state = ' ') game.put() game_link = 'http://localhost:8081/join?g=' + game_key token = channel.create_channel(player.user_id() + game_key) template_values = {'token': token, 'me': player.user_id(), 'mode': 2, 'game_key': game_key, 'game_link': game_link, 'initial_message': GameUpdater(game).get_game_message() } path = os.path.join(os.path.dirname(__file__), '../html/game.html') self.response.out.write(template.render(path, template_values)) else: self.redirect(users.create_login_url(self.request.uri))