-1

I am trying to deploy the flask app on heroku. But it is not deploying I thought that there is a problem in the Procfile please help me. my directory structure is as shown

app

  /website

      /template

      /static

      /__init__.py
      
     /view.py

     /auth.py

  /app.py

  /requirement.txt

  /Procfile.txt

and

app.py contain:


if __name__=="__main__":
          
        app=create_app()
          
        app.run(debug=True, port=2000)

init.py contain

from flask import Flask,render_template
from flask_sqlalchemy import SQLAlchemy
from os import path
from flask_login import LoginManager
import json

with open('website\config.json', 'r') as c:
                    params = json.load(c)["params"]


db=SQLAlchemy()

DB_NAME="database.db"

def create_app():
          app=Flask(__name__)
          app.config["SECRET_KEY"]="helloworld"
          app.config["SQLALCHEMY_DATABASE_URI"]= f'sqlite:///{DB_NAME}'
          db.init_app(app)
          
          from .views import views
          from .auth import auth

          app.register_blueprint(views, url_prefix="/")
          app.register_blueprint(auth, url_prefix="/")

          from .models import Users

          create_database(app)
          
          login_manager= LoginManager()
          login_manager.login_view="auth.login"
          login_manager.init_app(app)

          @login_manager.user_loader
          def load_user(id):
                    return Users.query.get(int(id))

          return app

def create_database(app):
          if not path.exists("website/"+ DB_NAME):
                    db.create_all(app=app)
                     

I tried with Procfile contain

web: gunicorn app:app

but it is not working.

I had seen many videos on youtube on deploying but in that in command line they get:

Procfile declares types -> web

but I got:

Procfile declares types -> (none)

Please Help.

davidism
  • 121,510
  • 29
  • 395
  • 339
Dev Sapariya
  • 151
  • 2
  • 9

1 Answers1

1

I agree with mechanical_meat's comment on your question. If your Procfile has a .txt extension it won't be detected. Remove it's extension and if it still does not work then there is a problem with something other than your Procfile.

Heroku Gunicorn Procfile, this shoud help.