@Old_TyT

Как задеплоить FLASK на heroku, используя gunicorn?

Подскажите как задеплоить сайт на heroku

#runtime.txt
python-3.8.10


#Procfile
web: gunicorn app:wsgi


#wsgi.py
from app import *

if __name__ == "__main__":
    app.run()


#__init__.py

from flask import Flask
from config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager

app = Flask(__name__)
login = LoginManager(app)
login.login_message = "Войдите, чтобы открыть эту страницу."
app.config.from_object(Config)
db = SQLAlchemy(app)
app.config['RECAPTCHA_PUBLIC_KEY'] = ""
app.config['RECAPTCHA_PRIVATE_KEY'] = ""
app.config['RECAPTCHA_PARAMETERS'] = {'hl': 'ru'}
from app import routes, models
migrate = Migrate(app, db)
login.login_view = 'login'


#каталог
├── Procfile
├── requirements.txt
├── runtime.txt
└── venv
    ├── androm.db
    ├── androm.py
    ├── app
    │   ├── __init__.py
    │   ├── forms.py
    │   ├── models.py
    │   ├── routes.py
    │   ├── static
    │   └── templates
    ├── config.py
    ├── db_create.py
    ├── db_migrate.py
    ├── heroku.yml
    ├── pyvenv.cfg
    └── wsgi.py


Вот ошибка с heroky
2021-10-27T09:25:32.071401+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-27T09:25:40.384922+00:00 heroku[web.1]: Starting process with command `gunicorn app:wsgi`
2021-10-27T09:25:41.430549+00:00 heroku[web.1]: Process exited with status 3
2021-10-27T09:25:41.278266+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-10-27T09:25:41.278652+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [4] [INFO] Listening at: http://0.0.0.0:44833 (4)
2021-10-27T09:25:41.278697+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [4] [INFO] Using worker: sync
2021-10-27T09:25:41.281426+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [10] [INFO] Booting worker with pid: 10
2021-10-27T09:25:41.284015+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [10] [ERROR] Exception in worker process
2021-10-27T09:25:41.284016+00:00 app[web.1]: Traceback (most recent call last):
2021-10-27T09:25:41.284016+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-10-27T09:25:41.284017+00:00 app[web.1]: worker.init_process()
2021-10-27T09:25:41.284017+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-10-27T09:25:41.284017+00:00 app[web.1]: self.load_wsgi()
2021-10-27T09:25:41.284017+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-10-27T09:25:41.284018+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-10-27T09:25:41.284018+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-10-27T09:25:41.284018+00:00 app[web.1]: self.callable = self.load()
2021-10-27T09:25:41.284018+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-10-27T09:25:41.284018+00:00 app[web.1]: return self.load_wsgiapp()
2021-10-27T09:25:41.284019+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-10-27T09:25:41.284019+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-10-27T09:25:41.284019+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
2021-10-27T09:25:41.284019+00:00 app[web.1]: mod = importlib.import_module(module)
2021-10-27T09:25:41.284019+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-10-27T09:25:41.284020+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-10-27T09:25:41.284020+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-10-27T09:25:41.284020+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-10-27T09:25:41.284020+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
2021-10-27T09:25:41.284021+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2021-10-27T09:25:41.284088+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [10] [INFO] Worker exiting (pid: 10)
2021-10-27T09:25:41.306262+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [4] [INFO] Shutting down: Master
2021-10-27T09:25:41.306305+00:00 app[web.1]: [2021-10-27 09:25:41 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-10-27T09:25:41.529042+00:00 heroku[web.1]: State changed from starting to crashed
  • Вопрос задан
  • 82 просмотра
Решения вопроса 1
ramzis
@ramzis
FullStackOverflow
Проблема решена, прошу закрыть вопрос.
Структура проекта неправильная.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы