0

Following this tutorial: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world

Based on the tutorial (first chapter), created this diagram:

enter image description here

Using VS Code (provided as part of CS50 courses on Edx).

After running this command on the terminal:

pip install Flask

Created microblog directory. I am approaching this without virtual environment.

Under microblog directory, app directory with 2 files:

  1. init.py

    from flask import Flask app = Flask(name) from app import routes

  2. routes.py

    from app import app @app.route('/') @app.route('/index') def index(): return "Hello World!"

Created microblog.py within microblog directory:

from app import app

Next, on the terminal, ran this command while within microblog directory:

export FLASK_APP=microblog.py

Finally, this command on terminal while on microblog directory:

flask run

This is the output on the terminal:

    microblog/ $ flask run
Traceback (most recent call last):
  File "/opt/cs50/lib/flask", line 19, in 
<module>
    sys.exit(flask.cli.main())
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site- 

packages/flask/cli.py", line 1107, in main cli.main() File "/usr/local/lib/python3.12/site- packages/click/core.py", line 1077, in main with self.make_context(prog_name, args, **extra) as ctx:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ microblog/ $ File "/usr/local/lib/python3.12/site- packages/flask/cli.py", line 662, in make_context load_dotenv() File "/usr/local/lib/python3.12/site- packages/flask/cli.py", line 739, in load_dotenv path = dotenv.find_dotenv(name, usecwd=True) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'dotenv' has no attribute 'find_dotenv'

Help appreciated where I am going wrong.

0 Answers0