<commit_before>from flask import Flask, jsonify, json
from datetime import datetime, timedelta
from os import getloadavg
import scraper
import os
import configparser

app = Flask(__name__)

config = configparser.ConfigParser()
config.read("config.ini")

@app.route("/cities")
def get_city_list():
    return jsonify({
        "supported_cities": [
            "Dresden",
            "Ingolstadt",
            "Luebeck"
        ]
    })

@app.route("/status")
def get_api_status():
    return jsonify({
        "status": "online",
        "servertime": datetime.now(),
        "load": getloadavg()
    })

@app.route("/<city>")
def get_lots(city):
    try:
        file = open("./cache/" + city + ".json", "r")
        last_json = file.read()
        last_json = json.loads(last_json)
        last_downloaded = datetime.strptime(last_json["last_downloaded"], "%Y-%m-%d %H:%M:%S")
        if datetime.now() - last_downloaded <= timedelta(minutes=10):
            print("Using cached data, oh yeah!")
            return jsonify(last_json)
        else:
            return jsonify(scraper.live(city))
    except FileNotFoundError:
        return jsonify(scraper.live(city))

# @app.route("/<city>/<lot_id>")
# def get_lot_details(city, lot_id):
#     if city == "Dresden":
#         return Dresden.get_lot_details(lot_id)

if __name__ == "__main__":
    if os.getenv("env") == "development":
        app.run(debug=True)
    else:
        app.run(host=config["Server"]["host"], port=int(config["Server"]["port"]))
<commit_msg>Most important route of all! 418 all the way<commit_after>from flask import Flask, jsonify, json, abort
from datetime import datetime, timedelta
from os import getloadavg
import scraper
import os
import configparser

app = Flask(__name__)

config = configparser.ConfigParser()
config.read("config.ini")

@app.route("/cities")
def get_city_list():
    return jsonify({
        "supported_cities": [
            "Dresden",
            "Ingolstadt",
            "Luebeck"
        ]
    })

@app.route("/status")
def get_api_status():
    return jsonify({
        "status": "online",
        "servertime": datetime.now(),
        "load": getloadavg()
    })

@app.route("/<city>")
def get_lots(city):
    try:
        file = open("./cache/" + city + ".json", "r")
        last_json = file.read()
        last_json = json.loads(last_json)
        last_downloaded = datetime.strptime(last_json["last_downloaded"], "%Y-%m-%d %H:%M:%S")
        if datetime.now() - last_downloaded <= timedelta(minutes=10):
            print("Using cached data, oh yeah!")
            return jsonify(last_json)
        else:
            return jsonify(scraper.live(city))
    except FileNotFoundError:
        return jsonify(scraper.live(city))

# @app.route("/<city>/<lot_id>")
# def get_lot_details(city, lot_id):
#     if city == "Dresden":
#         return Dresden.get_lot_details(lot_id)

@app.route("/coffee")
def make_coffee():
    abort(418)

if __name__ == "__main__":
    if os.getenv("env") == "development":
        app.run(debug=True)
    else:
        app.run(host=config["Server"]["host"], port=int(config["Server"]["port"]))

{'fraction_non_alphanumeric': 0.15620019126554033, 'fraction_numerical': 0.0031877590054191903, 'mean_word_length': 2.957124842370744, 'pattern_counts': {'":': 14, '<': 11, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1001301', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1035, 'n_words': 213}