@app.route('/')
def main_page():
 user = users.get_current_user()
 game_key = request.args.get('g')
 if (not game_key):
  game_key = user.user_id()
  game = Game(id=game_key, userX=user, moveX=True, board=(' ' * 9))
  game.put()
 else:
  game = Game.get_by_id(game_key)
  if (not game):
   return ('No such game', 404)
  if (not game.userO):
   game.userO = user
   game.put()
 channel_id = (user.user_id() + game_key)
 client_auth_token = create_custom_token(channel_id)
 _send_firebase_message(channel_id, message=game.to_json())
 game_link = '{}?g={}'.format(request.base_url, game_key)
 template_values = {'token': client_auth_token, 'channel_id': channel_id, 'me': user.user_id(), 'game_key': game_key, 'game_link': game_link, 'initial_message': urllib.unquote(game.to_json())}
 return flask.render_template('fire_index.html', **template_values)

@ app . route ( '/' ) def main_page ( ) : user = users . get_current_user ( ) game_key = request . args . get ( 'g' ) if ( not game_key ) : game_key = user . user_id ( ) game = Game ( id = game_key , userX = user , moveX = True , board = ( ' ' * 9 ) ) game . put ( ) else : game = Game . get_by_id ( game_key ) if ( not game ) : return ( 'No such game' , 404 ) if ( not game . userO ) : game . userO = user game . put ( ) channel_id = ( user . user_id ( ) + game_key ) client_auth_token = create_custom_token ( channel_id ) _send_firebase_message ( channel_id , message = game . to_json ( ) ) game_link = '{}?g={}' . format ( request . base_url , game_key ) template_values = { 'token' : client_auth_token , 'channel_id' : channel_id , 'me' : user . user_id ( ) , 'game_key' : game_key , 'game_link' : game_link , 'initial_message' : urllib . unquote ( game . to_json ( ) ) } return flask . render_template ( 'fire_index.html' , ** template_values )
renders the main page .