Search code examples
flaskherokuweb-deployment

error while deploying flask app on heroku : Failed to find attribute 'app' in 'app'


i am trying to deploy my very simple flask app on heroku but when i try to access my heroku app its giving me this error: An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. i checked logs from the terminal and it says: Failed to find attribute 'app' in 'app'.

Code

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "VatsalayKhobragade.me"

Project Structure

*

Procifle

web: gunicorn app:app

Requirements.txt

click==7.1.2
Flask==1.1.2
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
Werkzeug==1.0.1

Please Help with this. what i am doing wrong here ??


Solution

  • Probably could be solved with the procfile:

    web: gunicorn app.app:app


    Although for clarity you may wish to rename the top-level app folder to something different, then have:

    web: gunicorn something.app:app

    Or create a something/__init__.py file with the contents:

    from .app import app

    Then simply have a procfile with:

    web: gunicorn something:app