我正试图在Heroku上部署一个JustPy应用程序。我对两者都是新手。
基码,来自https://justpy.io/tutorial/getting_started/
# saved as app.py
import justpy as jp
app = jp.app # added for deployment
def hello_world():
wp = jp.WebPage()
jp.Hello(a=wp)
return wp
jp.justpy(hello_world)若要部署到Heroku帐户,请从以下https://devcenter.heroku.com/articles/heroku-cli获取Heroku工具
从您的项目文件夹:
pip install gunicorn
pip freeze > requirements.txt
# create Procfile web:- gunicorn app:app
# create runtime.txt:- Python 3.9.5
heroku login
heroku create justpyhi
git init
git add .
git config --global user.email "myemail@hotmail.com"
git config --global user.name "whateverusername"
git commit -m "first commit"
heroku git:remote --app justpyhi
git push heroku master
heroku open...and我得到以下错误:
Starting process with command `gunicorn mainheroku l`
app[web.1]: bash: gunicorn: command not found
heroku[web.1]: Process exited with status 127
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: State changed from crashed to starting
app[api]: Build succeeded更新:我得到了进一步的错误:
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed我做错了什么?感谢所有的帮助!
发布于 2022-10-17 13:26:33
请参阅https://devcenter.heroku.com/articles/getting-started-with-python?singlepage=true#define-a-procfile
你只需要三个文件:
requirements.txt
# https://github.com/justpy-org/justpy
# install justpy
justpyProcfile
web: python hello_world.pyhello_world.py
# saved as app.py
import justpy as jp
import os
app = jp.app # added for deployment
def hello_world():
wp = jp.WebPage()
jp.Hello(a=wp)
return wp
port=os.environ['PORT']
jp.justpy(hello_world,port=port,host='0.0.0.0')主要问题是通过" port“环境变量从heroku获取分配的端口,并将主机设置为'0.0.0.0‘以侦听所有接口。
看见
https://stackoverflow.com/questions/67575375
复制相似问题