I've been on and off, coding away at CS50 projects for some years now and I was really excited seeing the course moving away from PHP and into the elegant Python. Now, I want to recreate C$50 Finance in Python, a project I've already made in PHP, but I have a problem with running flask. At first, the command $ flask run gave me the error

error: Could not locate Flask application. You did not provide the FLASK_APP environment variable.

Some research online led me to Flask's site 'http://flask.pocoo.org/docs/0.12/quickstart/', where it tells me an example of a minimal Flask app, but all this code (including more) is already in application.py. As recommended there, I used export FLASK_APP=application.py, now using flask run seems to do the trick. I get the following message:

 * Serving Flask app "application"
 * Running on (Press CTRL+C to quit)

Using, as per pset7's directions, CS50IDE -> Web server, I arrive at my website, where it, sadly, tells me that No application seems to be running here!

Does anyone have any idea what's going wrong here?

Thanks in advance!

  • 1
    While it does not explain your problem, flask run --host= --port=8080 should start it on the right interface and port.
    – Blauelf
    Commented Mar 6, 2017 at 13:45

1 Answer 1

  • update50 to the latest version (98 as of this writing). That should update the environment (ie FLASK_APP)
  • make sure there is an application.py in the directory where you call flask run

If all else fails, restart your workspace (which makes a great answer if you know ahead of time it will work! :). I generally hate "reboot" as an answer, but it works so often and costs so little (in time on the IDE, not like rebooting a Windows PC), it is always worth a try.

  • Thanks for your reply! I ran update50 again (did it previously) and it was already on version 98. ~/workspace/pset7/finance/ $ flask run * Serving Flask app "application" * Running on (Press CTRL+C to quit) ls ^C~/workspace/pset7/finance/ $ ls application.py finance.db helpers.py requirements.txt static/ templates/ is what I got, and I still got the same problem Commented Mar 6, 2017 at 12:39
  • 1
    Well this is wrong. FWIW should be Which sounds( to me) like an environment problem too. I'm still tracking down where flask env vars get set. For grins, have you tried restarting your workspace? Commented Mar 6, 2017 at 13:30
  • Uhm... Now I feel just really stupid -.- I guess that was the problem, it seems to work now Restarted, it indeed gave (If you edit your answer to include the suggestion to restart, I'll mark it as answered :p ) Commented Mar 6, 2017 at 13:34

You must log in to answer this question.

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