简体   繁体   English

将用一个文件编写的Flask应用程序部署到Heroku

[英]Deploying Flask application written in one file to Heroku

I've built a flask app and I tread to deploy it on Heroku but I got this error: 我已经构建了一个Flask应用程序,并努力将其部署在Heroku上,但是出现了以下错误:

(venv) MacBook-Pro-alkhas-b-shosha:myApp joodi$ git push heroku master
error: src refspec master does not match any.
error: failed to push some refs to 'https://git.heroku.com/<app-name>.git'

I think the problem because I wrote all the application on one file. 我认为是问题所在,因为我将所有应用程序都写在一个文件上。 This my app structure: 这是我的应用程序结构:

在此处输入图片说明

all Flask code is in flasker.py . Flask的所有代码都在flasker.py

So when I start writing on Procfile I got confused, I didn't know what I supposed to write on it, here what I wrote 因此,当我开始在Procfile书写时,我很困惑,我不知道该写些什么,这是我写的

web: gunicorn myApp:app

What can I do without changing the structure? 不更改结构怎么办?

Your error message hints to you not being on the master branch. 您的错误消息提示您不在master分支上。

Try this: 尝试这个:

git push heroku your_branch:master

There are a couple of issues here. 这里有几个问题。

Git issue Git问题

error: src refspec master does not match any. 错误:src refspec master不匹配。

It looks like you haven't committed any code (Git can't find a master branch on your local system). 似乎您尚未提交任何代码(Git在本地系统上找不到master分支)。 git push operates on commits, not files. git push操作的是提交,而不是文件。

Make sure to commit your code locally before trying to push to Heroku. 在尝试推送到Heroku之前,请确保在本地提交代码。

Procfile issue Procfile问题

Also, update your Profile to point to your flasker.py file. 另外,更新您的Profile以指向您的flasker.py文件。 Assuming your Flask object is called app : 假设您的Flask对象称为app

web: gunicorn flasker:app

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM