<commit_before>import pdb
import logging
import urllib
import pdb
import os
import sys
import pytesseract
import requests

from forms import *
from PIL import Image
from logging import Formatter, FileHandler
from flask import Flask, render_template, request, jsonify
from ocr import process_image
from StringIO import StringIO

app = Flask(__name__)

@app.route('/ocr', methods=["POST"])
def ocr():
    try:
        return jsonify(process_image(request.form.keys()[0]))
    except:
        return jsonify({"error":"ocr error with image, did you send the proper url?"})

@app.errorhandler(500)
def internal_error(error):
    print str(error)

@app.errorhandler(404)
def not_found_error(error):
    print str(error)

if not app.debug:
    file_handler = FileHandler('error.log')
    file_handler.setFormatter(
        Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')
    )
    app.logger.setLevel(logging.INFO)
    file_handler.setLevel(logging.INFO)
    app.logger.addHandler(file_handler)
    app.logger.info('errors')

if __name__ == '__main__':
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)<commit_msg>clean up post request route<commit_after>import logging
import urllib
import pdb
import os
import sys
import pytesseract
import requests

from forms import *
from PIL import Image
from logging import Formatter, FileHandler
from flask import Flask, render_template, request, jsonify
from ocr import process_image
from StringIO import StringIO

app = Flask(__name__)

@app.route('/ocr', methods=["POST"])
def ocr():
    try:
        url = request.form.keys()[0]
        output = process_image(url)
        return jsonify({"output":output})
    except:
        return jsonify({"error":"ocr error with image, did you send the proper url?"})

@app.errorhandler(500)
def internal_error(error):
    print str(error)

@app.errorhandler(404)
def not_found_error(error):
    print str(error)

if not app.debug:
    file_handler = FileHandler('error.log')
    file_handler.setFormatter(
        Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')
    )
    app.logger.setLevel(logging.INFO)
    file_handler.setLevel(logging.INFO)
    app.logger.addHandler(file_handler)
    app.logger.info('errors')

if __name__ == '__main__':
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)
{'fraction_non_alphanumeric': 0.1252079866888519, 'fraction_numerical': 0.012479201331114808, 'mean_word_length': 4.428893905191874, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, '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': '7444089', 'n_tokens_mistral': 808, 'n_tokens_neox': 788, 'n_words': 199}