<commit_before>from flask import jsonify, request, redirect, abort
from nestedict import Nestedict
from werkzeug.utils import redirect

from start import app,  sanitize, dir_manager, staged



@app.route('/stage/add/<entry>')
def stage_add(entry):
    if dir_manager.found_entry(sanitize(entry)) is not None:
        staged.append(entry)
    return redirect("/")


@app.route('/stage')
def stage():
    return jsonify({"queue": staged})


@app.route('/stage/save/', methods=["POST", "GET"])
def stage_save():
    if request.method == "POST":
        text = request.form['text']
        playlist.createplaylist(staged, text)
        return  redirect("/")
    elif request.method == "GET":
        return '''
    <!doctype html>
    <title>Save Playlist</title>
    <h1>Playlist Name</h1>
    <form action="/stage/save/" method=post>
      <p><input type=text name=text>
         <input type=submit value=Send>
    </form>
    '''
    else:
        print "UPS" \
              ""
        abort(400)


@app.route('/stage/clear/')
def stage_clear():
    staged = []
    return redirect("/")


@app.route('/stage.json')
def stage_json():
    ndict = Nestedict("Playing Queue", 1)
    for entry in staged:
        ndict.add_node("Playing Queue/" + unicode(entry), 1)
    return jsonify(dict(ndict))<commit_msg>Cleaning stage was broken.<commit_after>from flask import jsonify, request, redirect, abort
from nestedict import Nestedict
from werkzeug.utils import redirect

from start import app,  sanitize, dir_manager, staged



@app.route('/stage/add/<entry>')
def stage_add(entry):
    if dir_manager.found_entry(sanitize(entry)) is not None:
        staged.append(entry)
    return redirect("/")


@app.route('/stage')
def stage():
    global staged
    return jsonify({"queue": staged})


@app.route('/stage/save/', methods=["POST", "GET"])
def stage_save():
    global staged
    if request.method == "POST":
        text = request.form['text']
        playlist.createplaylist(staged, text)
        return  redirect("/")
    elif request.method == "GET":
        return '''
    <!doctype html>
    <title>Save Playlist</title>
    <h1>Playlist Name</h1>
    <form action="/stage/save/" method=post>
      <p><input type=text name=text>
         <input type=submit value=Send>
    </form>
    '''
    else:
        print "UPS" \
              ""
        abort(400)


@app.route('/stage/clear/')
def stage_clear():
    global staged
    staged = []
    return redirect("/")


@app.route('/stage.json')
def stage_json():
    global staged
    ndict = Nestedict("Playing Queue", 1)
    for entry in staged:
        ndict.add_node("Playing Queue/" + unicode(entry), 1)
    return jsonify(dict(ndict))
{'fraction_non_alphanumeric': 0.1518752320831786, 'fraction_numerical': 0.0051986632008912, 'mean_word_length': 3.014903129657228, 'pattern_counts': {'":': 6, '<': 25, '<?xml version=': 0, '>': 25, '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': '7125279', 'n_tokens_mistral': 889, 'n_tokens_neox': 854, 'n_words': 210}