<commit_before>from flask import Flask, render_template, abort
from path import path
import settings
import lib
from rq import Connection, Queue
from redis import Redis

flapp = Flask(__name__)
flapp.debug = settings.DEBUG


redis_conn = Redis()
q = Queue(connection=redis_conn)


@flapp.route("/")
def hello():
    files = settings.APPS_DIR.listdir('*.app')
    apps = map(lambda app_file : lib.json_to_app(app_file), files)
    return render_template('hello.html', apps=apps)

@flapp.route("/app/<app_id>/")
def show_app(app_id):
    app = lib.app_id_to_data(app_id)
    return render_template('app.html', app=app)

@flapp.route("/app/<app_id>/deploy/")
def deploy_app(app_id):
    lib.app_exists(app_id)
    job = q.enqueue(lib.deploy_app, app_id)
    return ("Deployment added in queue, should be ok soon.<br>"
        +'<a href=".">Go back to app</a>')


if __name__ == "__main__":
    flapp.run()<commit_msg>Accept POST requests on /app/<app_id>/deploy<commit_after>from flask import Flask, render_template, abort
from path import path
import settings
import lib
from rq import Connection, Queue
from redis import Redis

flapp = Flask(__name__)
flapp.debug = settings.DEBUG


redis_conn = Redis()
q = Queue(connection=redis_conn)


@flapp.route("/")
def hello():
    files = settings.APPS_DIR.listdir('*.app')
    apps = map(lambda app_file : lib.json_to_app(app_file), files)
    return render_template('hello.html', apps=apps)

@flapp.route("/app/<app_id>/")
def show_app(app_id):
    app = lib.app_id_to_data(app_id)
    return render_template('app.html', app=app)

@flapp.route("/app/<app_id>/deploy/", methods=['GET', 'POST'])
def deploy_app(app_id):
    lib.app_exists(app_id)
    job = q.enqueue(lib.deploy_app, app_id)
    return ("Deployment added in queue, should be ok soon.<br>"
        +'<a href=".">Go back to app</a>')


if __name__ == "__main__":
    flapp.run()
{'fraction_non_alphanumeric': 0.1454352441613588, 'fraction_numerical': 0.0, 'mean_word_length': 4.511695906432749, 'pattern_counts': {'":': 2, '<': 14, '<?xml version=': 0, '>': 14, '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': '990425', 'n_tokens_mistral': 695, 'n_tokens_neox': 680, 'n_words': 159}