(Dont be intimidated by length of code chunks, I included all of my guess as to what's going on, so most of it is just stuff to skim over)

The folder similarities contains static and template folders (which are probably irrelevant to this question) application.py, helpers.py, compare and requirements.txt(irrelevant again).

Now I vaguely understand that somehow the command flask run in the terminal runs application.py through $FLASK_APP being set to it in the IDE. I also see that helpers.py is linked to this through

from helpers import lines, sentences, substrings

at the top of application.py. However, how is compare linked to any of this stuff? I can't find it at the top of application.py. See below

import cs50
import re
from flask import Flask, abort, redirect, render_template, request
from html import escape
from werkzeug.exceptions import default_exceptions, HTTPException

from helpers import lines, sentences, substrings

# Web app
app = Flask(__name__)

Here are my guesses as to what is going on:


flask run doesn't only run application.py but everything in the folder it's being run in, and thus compare is run

I can only assume that somehow the following lines of code compareat the top and bottom of the compare file play a role

#!/usr/bin/env python3

if __name__ == "__main__":


Somehow the code in the 'body' of application.py calls compare in a subtle way I'm not picking up. Here are some lines of code that I believe are the main suspects.

@app.route("/compare", methods=["POST"])
def compare():
    """Handle requests for /compare via POST"""

Otherwise I have no clue


The compare python program is for running on the command line, so you can test your helpers.py functions that you've written. It is unrelated to the web-based application.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .