1

I am currently taking CS50's Web Programming with Python and JavaScript class. I am trying to run a flask server however I am getting flask.cli.NoAppException error. I am trying to connect to a postGRES SQL database on heroku.

  • Running Mac OX Mojave version 10.14.4 and using bash command line
  • Able to connect to Adminer tool for project
  • Able to connect to heroku and View Credentials to obtain URI for flask environment
  • Confirmed all required packages are installed with pip3 install -r v requirements.txt
  • Tried using home-brew to update SSL
  • Tried Uninstalling psycopg2 library and installing psycopg2-binary library with pip

import os

from flask import Flask, session
from flask_session import Session
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker

app = Flask(__name__)

# Check for environment variable
if not os.getenv("DATABASE_URL"):
    raise RuntimeError("DATABASE_URL is not set!!!")

# Configure session to use filesystem
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

# Set up database
engine = create_engine(os.getenv("DATABASE_URL"))
db = scoped_session(sessionmaker(bind=engine))


@app.route("/")
def index():
    return "Project 1: TODO"

Bash Command Prompt:

Stephens-MacBook-Pro:Project1 stephen$ export FLASK_APP=application.py
Stephens-MacBook-Pro:Project1 stephen$ export FLASK_DEBUG=1
Stephens-MacBook-Pro:Project1 stephen$ export DATABASE_URL="postgres://qipeqvvmvvcoqf:1c6aaa3504a58aa2b9be46b85d79a05159f5ccb1f64e3e27070a024a02c3b83e@ec2-174-129-208-118.compute-1.amazonaws.com:5432/d3lrnl0okcg99k"
Stephens-MacBook-Pro:Project1 stephen$ flask run
 * Serving Flask app "application.py" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 334-645-143

When I open http://127.0.0.1:5000/ I should see the text "Project 1: TODO"!

Error Screenshot

2
  • Please include the error and traceback when asking debugging questions. Commented May 11, 2019 at 12:18
  • I have just added the error and traceback as a screenshot! Commented May 12, 2019 at 1:56

1 Answer 1

1

this happens usually when one or more packages are corrupted. try updating all packages using pip use the following command

pip install -I --ignore-installed -r requirements.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.