<commit_before>from flask import Flask, request, jsonify, render_template
import os
app = Flask(__name__)

from classifier import Classifier
# from downloader import Downloader

DEBUG = os.environ.get('DEBUG') != None
VERSION = 0.1

@app.route("/")
def index():
    """
    When you request the root path, you'll get the index.html template.

    """
    return render_template("index.html")

@app.route("/")
def root():
    return jsonify(dict(message='political affiliation prediction api', version=VERSION))

@app.route("/predict", methods=['POST'])
def predict():
    if request.form.has_key('url'):
        url = request.form['url']
        return jsonify(classifier.predict_url(url))
    else:
        text = request.form['text']
        return jsonify(classifier.predict(text))

if __name__ == "__main__":
    port = 5000
    classifier = Classifier()
    # Open a web browser pointing at the app.
    # os.system("open http://localhost:{0}".format(port))

    app.run(port = port, debug = DEBUG)<commit_msg>Bind to all interfaces<commit_after>from flask import Flask, request, jsonify, render_template
import os
app = Flask(__name__)

from classifier import Classifier
# from downloader import Downloader

DEBUG = os.environ.get('DEBUG') != None
VERSION = 0.1

@app.route("/")
def index():
    """
    When you request the root path, you'll get the index.html template.

    """
    return render_template("index.html")

@app.route("/")
def root():
    return jsonify(dict(message='political affiliation prediction api', version=VERSION))

@app.route("/predict", methods=['POST'])
def predict():
    if request.form.has_key('url'):
        url = request.form['url']
        return jsonify(classifier.predict_url(url))
    else:
        text = request.form['text']
        return jsonify(classifier.predict(text))

if __name__ == "__main__":
    port = 5000
    classifier = Classifier()
    # Open a web browser pointing at the app.
    # os.system("open http://localhost:{0}".format(port))

    app.run(host='0.0.0.0', port = port, debug = DEBUG)
{'fraction_non_alphanumeric': 0.14257907542579076, 'fraction_numerical': 0.008759124087591242, 'mean_word_length': 3.759259259259259, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2899818', 'n_tokens_mistral': 635, 'n_tokens_neox': 612, 'n_words': 173}