<commit_before>import requests
from flask import Flask, render_template

app = Flask(__name__, instance_relative_config=True)
app.config.from_pyfile("appconfig.py")

sources = {
    "bbc": "bbc-news",
    "cnn": "cnn",
    "hackernews": "hacker-news"
}

def create_link(source):
    if source in sources.keys():
        return f"https://newsapi.org/v1/articles?source={sources[source]}&sortBy=top&apiKey={app.config['API_KEY']}"
    

@app.route("/")
@app.route("/<source>")
def index(source="bbc"):
    r = requests.get(create_link(source))
    return render_template("index.html", articles=r.json().get("articles"), source=source)


if __name__ == "__main__":
    app.run()<commit_msg>Use GET request arguments to determine the news source.<commit_after>import requests
from flask import Flask, render_template, request

app = Flask(__name__, instance_relative_config=True)
app.config.from_pyfile("appconfig.py")

sources = {
    "bbc": "bbc-news",
    "cnn": "cnn",
    "hackernews": "hacker-news"
}


def create_link(source):
    if source in sources.keys():
        return f"https://newsapi.org/v1/articles?source={sources[source]}&sortBy=top&apiKey={app.config['API_KEY']}"
    

@app.route("/")
def index():
    query = request.args.get("source")
    if query is None or query.lower() not in sources.keys():
        source = "bbc"
    else:
        source = query.lower()
    r = requests.get(create_link(source))
    return render_template("index.html", articles=r.json().get("articles"), source=source)


if __name__ == "__main__":
    app.run()
{'fraction_non_alphanumeric': 0.16602316602316602, 'fraction_numerical': 0.001287001287001287, 'mean_word_length': 4.418118466898955, 'pattern_counts': {'":': 8, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '686932', 'n_tokens_mistral': 529, 'n_tokens_neox': 523, 'n_words': 103}