我的烧瓶 Heroku 尝试失败,我无法查明问题所在

My flask Heroku attempt fails, i cannot pinpoint the problem

所以我尝试使用 Heroku 为 运行 制作一个非常简单的测试应用程序。这是我从头开始的第三次尝试。我有一个 python 文件,内容非常少

from flask import Flask

app = Flask(__name__)

@app.route("/")
def test():
    return "test"

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

文件名为test.py,我的目录还包括Procfile

web: gunicorn app:test

和requirments.txt

click==7.1.2
Flask==1.1.2
gunicorn==20.1.0
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==1.1.1
Werkzeug==1.0.1

最重要的是,我 git忽略以确保 IDE 文件不会干扰,

.idea
.Heroku.iml

和runtime.txt

python-3.6.0

然后我尝试使用

创建一个应用程序
heroku create <appname>

然后我在命令

中使用第二个URL它returns
git remote add heroku <url>

。然后我做

git add . 
git commit -m "some message"
git push heroku main

并得到以下错误。

To https://git.heroku.com/forgotten-fox.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'

然后我尝试使用

git push heroku master

相反,但没有发生任何变化。 我还尝试强制它使用 python build pack 和

heroku buildpack:set heroku/python --app <appname>

如上错误所述

Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure

我主要不知道如何使用 git,但我的朋友建议我创建远程存储库并将其附加到 Heroku,但我找不到如何执行附件。

如果有人知道是什么原因造成的和/或如何解决它,如果您能分享这些知识,我将不胜感激。

更新:

感谢您指出需求文件的错误名称,我已将其重命名。我还将我的 Procfile 更改为

web: gunicorn test:app

。 遗憾的是它没有解决问题(是的,我确实提交并推动了所做的更改)。 以下是错误消息:

对于 git push heroku master :

Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 6 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.66 KiB | 1.66 MiB/s, done.
Total 11 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 36fb38193ecf8aa8d27f79682de049be81cb8807
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 36fb38193ecf8aa8d27f79682de049be81cb8807
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to forgotten-fox.
remote:
To https://git.heroku.com/forgotten-fox.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'

这里是 git heroku push main:

error: src refspec main does not match any
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'

.

更新 好吧,对不起大家,我一般都是弱智。我错过了关于重建错误的明显部分,here 它说明了我的应用程序运行所需的最终修复。

问题是您必须使用

web: gunicorn test:app

而不是

web: gunicorn app:test

正确的格式是

gunicorn <filename>:<app object>