<commit_before>import argparse
import syslog
import json
from flask import Flask, request, make_response
from jobs import add_job, get_jobs, job_results
from jobs import BadRequestError, NotFoundError, InternalError


app = Flask(__name__)


def _make_error(status, message):
    error = {}
    error['code'] = status
    error['message'] = message
    error['fields'] = ""
    resp = make_response(json.dumps(error), status)
    resp.headers['Content-Type'] = 'application/json'
    return resp


def _make_response(status=200, response=None):
    resp = make_response(json.dumps(response), status)
    resp.headers['Content-Type'] = 'application/json'
    return resp


@app.route('/jobs/', methods=['GET', 'POST'])
def get_post_jobs():
    if request.method == 'POST':
        job = request.json
        try:
            return _make_response(add_job(job))
        except BadRequestError as e:
            return _make_error(400, e.message)
        except Exception as e:
            return _make_error(500, e.message)
    else:
        start_pos = request.args.get('start_pos', None)
        item_count = request.args.get('item_count', None)
        try:
            return _make_response(
                get_jobs(
                    start_pos=start_pos,
                    item_count=item_count))
        except BadRequestError as e:
            return _make_error(400, e.message)
        except Exception as e:
            return _make_error(500, e.message)


@app.route('/jobs/results/', methods=['GET'])
def get_jobs_results():
    start_time = request.args.get('start_time', None)
    end_time = request.args.get('end_time', None)
    start_pos = request.args.get('start_pos', None)
    item_count = request.args.get('item_count', None)
    try:
        return _make_response(
            job_results(
                job_id=None,
                start_time=start_time, 
                end_time=end_time, 
                start_pos=start_pos, 
                item_count=item_count))
    except BadRequestError as e:
        return _make_error(400, e.message)
    except Exception as e:<commit_msg>Fixed a problem with parameter passing to the _make_response method.<commit_after>import argparse
import syslog
import json
from flask import Flask, request, make_response
from jobs import add_job, get_jobs, job_results
from jobs import BadRequestError, NotFoundError, InternalError


app = Flask(__name__)


def _make_error(status, message):
    error = {}
    error['code'] = status
    error['message'] = message
    error['fields'] = ""
    resp = make_response(json.dumps(error), status)
    resp.headers['Content-Type'] = 'application/json'
    return resp


def _make_response(status=200, response=None):
    resp = make_response(json.dumps(response), status)
    resp.headers['Content-Type'] = 'application/json'
    return resp


@app.route('/jobs/', methods=['GET', 'POST'])
def get_post_jobs():
    if request.method == 'POST':
        job = request.json
        try:
            return _make_response(response=add_job(job))
        except BadRequestError as e:
            return _make_error(400, e.message)
        except Exception as e:
            return _make_error(500, e.message)
    else:
        start_pos = request.args.get('start_pos', None)
        item_count = request.args.get('item_count', None)
        try:
            return _make_response(response=get_jobs(
                    start_pos=start_pos,
                    item_count=item_count))
        except BadRequestError as e:
            return _make_error(400, e.message)
        except Exception as e:
            return _make_error(500, e.message)


@app.route('/jobs/results/', methods=['GET'])
def get_jobs_results():
    start_time = request.args.get('start_time', None)
    end_time = request.args.get('end_time', None)
    start_pos = request.args.get('start_pos', None)
    item_count = request.args.get('item_count', None)
    try:
        return _make_response(response=job_results(
                job_id=None,
                start_time=start_time, 
                end_time=end_time, 
                start_pos=start_pos, 
                item_count=item_count))
    except BadRequestError as e:
        return _make_error(400, e.message)
    except Exception as e:
{'fraction_non_alphanumeric': 0.10575573233504913, 'fraction_numerical': 0.008423022929340197, 'mean_word_length': 2.6758383490971624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1499520', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1252, 'n_words': 290}