<commit_before>from flask import Flask
from flask import render_template
from flask import request
from Core.DB import search_class
from Core.DB import update_db
import json
import ast
from bson.json_util import loads
import os

app = Flask(__name__)
APP_TITLE = "Cal Exam Archive"
PORT = int(os.environ.get('PORT', 5000))# For Heroku


@app.route("/")
def index():
    query = request.args.get("search")
    if query:
        query = query.lower()
    results = search_class(query)
    # results = ""

    title = "{main}{bar}{query}".format(main=APP_TITLE,
                                        query=query if query else "",
                                        bar=" | " if query else "")

    print("Render Index")
    return render_template("index.html",
                           title=title,
                           suggestion1="CS 61A",
                           suggestion2="Math 53",
                           suggestion3="Physics 7A",
                           suggestion4="EE 20",
                           results_json=results
                           )


@app.route("/attribution")
def attribution():
    return render_template("attribution.html",
                           title="{main} | Attribution".format(main=APP_TITLE))


if __name__ == '__main__':
    # app.run(debug=True, port=PORT)
    app.run(host='0.0.0.0', port=PORT)
    print("Updating DB")
    update_db()<commit_msg>attempt<commit_after>from flask import Flask
from flask import render_template
from flask import request
from Core.DB import search_class
from Core.DB import update_db
import json
import ast
from bson.json_util import loads
import os

app = Flask(__name__)
APP_TITLE = "Cal Exam Archive"
PORT = int(os.environ.get('PORT', 5000))# For Heroku


@app.route("/")
def index():
    update_db()
    query = request.args.get("search")
    if query:
        query = query.lower()
    results = search_class(query)
    # results = ""

    title = "{main}{bar}{query}".format(main=APP_TITLE,
                                        query=query if query else "",
                                        bar=" | " if query else "")

    print("Render Index")
    return render_template("index.html",
                           title=title,
                           suggestion1="CS 61A",
                           suggestion2="Math 53",
                           suggestion3="Physics 7A",
                           suggestion4="EE 20",
                           results_json=results
                           )


@app.route("/attribution")
def attribution():
    return render_template("attribution.html",
                           title="{main} | Attribution".format(main=APP_TITLE))


if __name__ == '__main__':
    # app.run(debug=True, port=PORT)
    app.run(host='0.0.0.0', port=PORT)
{'fraction_non_alphanumeric': 0.11297819091884162, 'fraction_numerical': 0.013585984983911333, 'mean_word_length': 1.8521916411824668, 'pattern_counts': {'":': 0, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6210734', 'n_tokens_mistral': 802, 'n_tokens_neox': 756, 'n_words': 185}