<commit_before>from flask import Flask, render_template, session, request
import os
import random
import string
from functools import wraps
from flask_socketio import SocketIO, emit

############### DEBUGGING ONLY
import socket
def prints(*args):
    print(socket.gethostbyname(socket.gethostname()), ':', *args)
###################

def random_string(length=16):
    pool = string.ascii_letters + string.digits
    return ''.join(random.choice(pool) for _ in range(length))

def templated(layout):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            func(*args, **kwargs)
            return render_template('index.html', layout=layout)
        return wrapper
    return decorator


BASE_PATH = os.path.dirname(os.path.abspath(__file__))

app = Flask(__name__, static_url_path='', static_folder=os.path.join(BASE_PATH, 'www'))
app.config.update(
    SECRET_KEY = b'\<KEY>',
    DEBUG = True
)
socketio = SocketIO(app)

queue = []
pairs = {}


@app.route('/')
@templated('start')
def home():
    pass

@app.route('/loading')
@templated('loading')
def loading():
    session['opponent'] = None
    # session.modified = True
    print('LOADING', session, queue)
    if 'id' not in session:
        session['id'] = random_string()
        prints('NEWID:', session['id'])
    if queue:
        session['opponent'] = queue.pop(0)
        # session.modified = True
        pairs[session['opponent']] = session['id']
        prints('FOUND:', session['opponent'], 'ID:', session['id'])
    else:
        prints('NOFOUND, ID:', session['id'])
        session['opponent'] = None
        # session.modified = True 
        queue.append(session['id'])

@app.route('/game')
def game():
    if session['opponent'] or (session['id'] in pairs):
        prints('ID:', session['id'], 'OPPONENT:', session['opponent'], 'PAIRS:', pairs)
        if not session['opponent']:
            session['opponent'] = pairs.pop(session['id'])
            # session.modified = True
            prints('FOUND', session['opponent'])
        return render_template('index.html', layout='game', id=session['id'], opponent=session['opponent'])
    else:
        return ('', 204)

@socketio.on('move')
def process_move(data):
    print(data)
    emit('moveOther', data, broadcast=True)


@app.route('/singleGame')<commit_msg>madfssk<commit_after>from flask import Flask, render_template, session, request
import os
import random
import string
from functools import wraps
from flask_socketio import SocketIO, emit


def random_string(length=16):
    pool = string.ascii_letters + string.digits
    return ''.join(random.choice(pool) for _ in range(length))

def templated(layout):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            func(*args, **kwargs)
            return render_template('index.html', layout=layout)
        return wrapper
    return decorator


BASE_PATH = os.path.dirname(os.path.abspath(__file__))

app = Flask(__name__, static_url_path='', static_folder=os.path.join(BASE_PATH, 'www'))
app.config.update(
    SECRET_KEY = b'\<KEY>',
    DEBUG = True
)
socketio = SocketIO(app)

queue = []
pairs = {}


@app.route('/')
@templated('start')
def home():
    pass

@app.route('/loading')
@templated('loading')
def loading():
    session['opponent'] = None
    # session.modified = True
    print('LOADING', session, queue)
    if 'id' not in session:
        session['id'] = random_string()
        print('NEWID:', session['id'])
    if queue:
        session['opponent'] = queue.pop(0)
        # session.modified = True
        pairs[session['opponent']] = session['id']
        print('FOUND:', session['opponent'], 'ID:', session['id'])
    else:
        print('NOFOUND, ID:', session['id'])
        session['opponent'] = None
        # session.modified = True 
        queue.append(session['id'])

@app.route('/game')
def game():
    print('ENTER ATTEMPT BY ID', session['id'], 'OPPONENT:', session['opponent'], 'PAIRS', pairs)
    if session['opponent'] or (session['id'] in pairs):
        print('SUCCESS!')
        if not session['opponent']:
            session['opponent'] = pairs.pop(session['id'])
            # session.modified = True
            print('FOUND', session['opponent'])
        return render_template('index.html', layout='game', id=session['id'], opponent=session['opponent'])
    else:
        return ('', 204)

@socketio.on('move')
def process_move(data):
    print('SEND DATA ID:', data['id'])
    emit('moveOther', data, broadcast=True)


@app.route('/singleGame')
{'fraction_non_alphanumeric': 0.17130949769686335, 'fraction_numerical': 0.002632156174599693, 'mean_word_length': 3.537313432835821, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4947307', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1415, 'n_words': 316}