我终于能够将我的应用程序部署到Heroku ..除非现在应用程序拒绝运行。 我的应用程序使用应用程序工厂,我在Windows上开发它。
我已经尝试创建一个runserver.py文件,该文件使用工厂的create_app()函数,然后在Procfile中将gunicorn指向它,就像web:gunicorn runserver:app但仍然没有。
这是我的项目布局:
adco_flask
| .env | .gitignore | config.py | Procfile | requirements.txt | runserver.py | |___app | __init__.py | email.py | models.py | admin/ | auth/ | errors/ | static/ | tables/ | templates/
Within app's init, here is the code:
imports...
basedir = os.path.abspath(os.path.dirname(__file__)) dotenv_path = os.path.join(basedir, '.env') load_dotenv(dotenv_path) db = SQLAlchemy() login_manager = LoginManager() mail = Mail() bootstrap = Bootstrap() def create_app(test_config=None): # create and configure the app app = Flask(__name__, instance_relative_config=True) if test_config is None: # load the instance config, if it exists, when not testing app.config.from_object(Config) else: # load the test config passed in app.config.from_object(test_config) db.init_app(app) migrate = Migrate(app, db) login_manager.init_app(app) mail.init_app(app) bootstrap.init_app(app) admin = Admin(app, name='ADCo', template_mode='bootstrap3', index_view=MyIndexView()) from app.auth import auth_bp app.register_blueprint(auth_bp) from app.tables import tables_bp app.register_blueprint(tables_bp) from app.errors import errors_bp app.register_blueprint(errors_bp) init_admin(admin) if not app.debug and not app.testing: if app.config['MAIL_SERVER']: auth = None if (app.config['MAIL_USERNAME'] or app.config['MAIL_PASSWORD']): auth = (app