<commit_before>from flask import Flask, request, jsonify, render_template, url_for, make_response
from flask_restful import Api
from werkzeug.contrib.fixers import ProxyFix

from resources import adding, add_activity, homepage


APP = Flask(__name__)
API = Api(APP)


API.add_resource(homepage.Homepage, '/')
API.add_resource(adding.AddNumbers, '/add')
API.add_resource(add_activity.AddActivity, '/add-activity')


@APP.route('/hello')
def hello():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>It's <a href="{}">me</a></h1>
        '''.format(url_for('me'))


@APP.route('/me')
def me():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>I'm in <a href="{}">California</a> dreaming</h1>
        '''.format(url_for('california'))


@APP.route('/cali')
def california():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>About who we used to <a href="{}">be</a></h1>
        '''.format(url_for('otherside'))


@APP.route('/otherside')
def otherside():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>Hello from the otherside</h1>
        '''


@APP.route("/images/<name>")
def images(name):
    # fullpath = url_for('static', filename=name)
    return '<img src=' + url_for('static', filename='images/{}'.format(name)) + '>'


@APP.errorhandler(adding.InvalidNumber)
def handle_invalid_number(error):
    response = jsonify(error.to_dict())
    response.status_code = error.status_code
    return response


if __name__ == '__main__':
    print "In __main__, running host..."
    APP.run(host='0.0.0.0', debug=True)

elif __name__ == 'app':
    # when we run using gunicorn
    print "WSGI setup..."
    APP.wsgi_app = ProxyFix(APP.wsgi_app)<commit_msg>Change port to 5005 to avoid conflicts<commit_after>from flask import Flask, request, jsonify, render_template, url_for, make_response
from flask_restful import Api
from werkzeug.contrib.fixers import ProxyFix

from resources import adding, add_activity, homepage


APP = Flask(__name__)
API = Api(APP)


API.add_resource(homepage.Homepage, '/')
API.add_resource(adding.AddNumbers, '/add')
API.add_resource(add_activity.AddActivity, '/add-activity')


@APP.route('/hello')
def hello():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>It's <a href="{}">me</a></h1>
        '''.format(url_for('me'))


@APP.route('/me')
def me():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>I'm in <a href="{}">California</a> dreaming</h1>
        '''.format(url_for('california'))


@APP.route('/cali')
def california():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>About who we used to <a href="{}">be</a></h1>
        '''.format(url_for('otherside'))


@APP.route('/otherside')
def otherside():
    return '''
        <!doctype html>
        <title>Add two numbers!</title>
        <h1>Hello from the otherside</h1>
        '''


@APP.route("/images/<name>")
def images(name):
    # fullpath = url_for('static', filename=name)
    return '<img src=' + url_for('static', filename='images/{}'.format(name)) + '>'


@APP.errorhandler(adding.InvalidNumber)
def handle_invalid_number(error):
    response = jsonify(error.to_dict())
    response.status_code = error.status_code
    return response


if __name__ == '__main__':
    print "In __main__, running host..."
    APP.run(host='0.0.0.0', port=5005, debug=True)

elif __name__ == 'app':
    # when we run using gunicorn
    print "WSGI setup..."
    APP.wsgi_app = ProxyFix(APP.wsgi_app)
{'fraction_non_alphanumeric': 0.17173913043478262, 'fraction_numerical': 0.008695652173913044, 'mean_word_length': 3.4349397590361446, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3461397', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1233, 'n_words': 272}