<commit_before>#!flask/bin/python

from flask import Flask, jsonify
from mining import Mining
from IR import IR
from datetime import date

app=Flask(__name__)


def get_json(year,month,day):
    ir=IR().getInfo(date(year,month,day))
    lst=Mining(ir).build()
    lstdict=[{'word': a[0],'value':a[1]} for a in lst ]
    return {'dict':lstdict}

@app.route('/api/miningDTH/v1.0/<int:year>/<int:month>/<int:day>',methods=['GET'])
def get_tasks(year,month,day):
    json=get_json(year,month,day)
    return jsonify(json)

if __name__=='__main__':
    app.run(debug=True)
<commit_msg>flask api with cache<commit_after>#!flask/bin/python

from flask import Flask, jsonify
from mining import Mining
from IR import IR
from datetime import date

app=Flask(__name__)

json_cache={}

def get_json(year,month,day):
    ir=IR().getInfo(date(year,month,day))
    lst=Mining(ir).build()
    lstdict=[{'word': a[0],'value':a[1]} for a in lst ]
    return {'dict':lstdict}

@app.route('/api/miningDTH/v1.0/<int:year>/<int:month>/<int:day>',methods=['GET'])
def get_tasks(year,month,day):
    json=json_cache.get((year,month,day),None)
    if not json:
        json=get_json(year,month,day)
        json_cache[(year,month,day)]=json

    return jsonify(json)

if __name__=='__main__':
    app.run(debug=True)

{'fraction_non_alphanumeric': 0.17337461300309598, 'fraction_numerical': 0.006191950464396285, 'mean_word_length': 5.216346153846154, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1147157', 'n_tokens_mistral': 504, 'n_tokens_neox': 489, 'n_words': 89}