<commit_before>""" main.py is the top level script.

Return "Hello World" at the root URL.
"""

import os
import sys

# sys.path includes 'server/lib' due to appengine_config.py
from flask import Flask , request
from flask import render_template
import urllib2
import json
import random
import uuid
from google.appengine.api import users
from google.appengine.api import channel
from utilities import funnames
app = Flask(__name__.split('.')[0])


@app.route('/')
def menu():
  """ Return hello template at application root URL."""
  return render_template('menu.html')

@app.route('/cards')
def oneplayer():
  """ Return hello template at application root URL."""
  return render_template('cards.html')

@app.route('/multi')
def multiplayer():
  """ Return hello template at application root URL."""
  return render_template('multi.html')

@app.route('/playernames')
def names():
  """ Return hello template at application root URL."""
  return render_template('playernames.html')

@app.route('/online_play')
def online_setup():
  """ Returns page for online setup"""
  roomid = generate_id()
  template_values = {"roomid":roomid}
  return render_template("online_setup.html",values=template_values)

@app.route('/<roomid>/<name>')
def host_setup(roomid,name):
    """Return a chat page"""
    token = channel.create_channel(name + roomid) 
    template_values = {
                       "roomid":roomid,
                        "token": token,
                        "yourname": name
                       }
    return render_template("host.html",values=template_values)



@app.route('/<roomid>/<name>/guest')
def nameget(roomid,name):
    """Return a chat page"""
    template_values = {
                       "roomid":roomid,
                        "opponent": name
                       }
    return render_template("guest_setup.html",values=template_values)



@app.route('/<roomid>/guest/<name>')
def guest_setup(roomid,name):
    """Return a chat page"""
    token = channel.create_channel(name + roomid) 
    template_values = {
                       "roomid":roomid,
                        "token": token,
                        "yourname": name
                       }
    return render_template("guest.html",values=template_values)



def generate_id():
    """Return a game id"""
    return "%s-%s" % (str(uuid.uuid4())[:4],random.choice(funnames).lower())<commit_msg>Allowed main to send stuff<commit_after>""" main.py is the top level script.

Return "Hello World" at the root URL.
"""

import os
import sys

# sys.path includes 'server/lib' due to appengine_config.py
from flask import Flask , request
from flask import render_template
import urllib2
import json
import random
import uuid
from google.appengine.api import users
from google.appengine.api import channel
from utilities import funnames
app = Flask(__name__.split('.')[0])


@app.route('/')
def menu():
  """ Return hello template at application root URL."""
  return render_template('menu.html')

@app.route('/cards')
def oneplayer():
  """ Return hello template at application root URL."""
  return render_template('cards.html')

@app.route('/multi')
def multiplayer():
  """ Return hello template at application root URL."""
  return render_template('multi.html')

@app.route('/playernames')
def names():
  """ Return hello template at application root URL."""
  return render_template('playernames.html')

@app.route('/online_play')
def online_setup():
  """ Returns page for online setup"""
  roomid = generate_id()
  template_values = {"roomid":roomid}
  return render_template("online_setup.html",values=template_values)

@app.route('/<roomid>/<name>')
def host_setup(roomid,name):
    """Return a chat page"""
    token = channel.create_channel(name + roomid) 
    template_values = {
                       "roomid":roomid,
                        "token": token,
                        "yourname": name
                       }
    return render_template("host.html",values=template_values)



@app.route('/<roomid>/<name>/guest')
def nameget(roomid,name):
    """Return a chat page"""
    template_values = {
                       "roomid":roomid,
                        "opponent": name
                       }
    return render_template("guest_setup.html",values=template_values)



@app.route('/<roomid>/guest/<name>')
def guest_setup(roomid,name):
    """Return a chat page"""
    token = channel.create_channel(name + roomid) 
    template_values = {
                       "roomid":roomid,
                        "token": token,
                        "yourname": name
                       }
    return render_template("guest.html",values=template_values)

@app.route('/sendmessage/<user>/<roomid>', methods=['GET', 'POST'])
def sendmessage(user,roomid):
    """sends a message that is useless"""
    message = request.form['message']
    channel.send_message(user+roomid,message)

def generate_id():
    """Return a game id"""
    return "%s-%s" % (str(uuid.uuid4())[:4],random.choice(funnames).lower())
{'fraction_non_alphanumeric': 0.13810282981267438, 'fraction_numerical': 0.0015942606616181746, 'mean_word_length': 3.02485966319166, 'pattern_counts': {'":': 18, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7256838', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1413, 'n_words': 367}