1

I'm trying to deploy a JustPy app on Heroku. I'm new to both.

Base code, from 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)

To deploy to a Heroku account, get the Heroku tools from: https://devcenter.heroku.com/articles/heroku-cli

From your project folder:

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 I get the following errors:

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

[Updated:] I'm getting this further error:

-----> 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

What am I doing wrong? All help gratefully received!

Roger
  • 70
  • 1
  • 9
  • Some of the answers here may help: https://stackoverflow.com/q/33021874/42346 Basically it seems worth a shot to uninstall requirements remotely, then reinstall. – mechanical_meat May 17 '21 at 18:50
  • Thanks for your reply! I've been thru everything on that page. I'll try going back to a very simple flask app and building up from there. Very frustrating tho. – Roger May 17 '21 at 20:17
  • 1
    In the same boat here. Been following instructions in https://justpy.io/tutorial/deployment/ and https://justpy.io/reference/justpy/ but could not make it work. My URL is showing: Internal Server Error. – Mike Aug 08 '21 at 16:23

1 Answers1

2

See https://devcenter.heroku.com/articles/getting-started-with-python?singlepage=true#define-a-procfile

You just need three files:

  1. requirements.txt
  2. Procfile
  3. hello_world.py

requirements.txt

# https://github.com/justpy-org/justpy
# install justpy
justpy

Procfile

web: python hello_world.py

hello_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')

The main issue is to pick up the assigned port from heroku via the "PORT" environment variable and to set the host to '0.0.0.0' to listen to all interfaces.

See

  1. https://stackoverflow.com/a/15693371/1497139
Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186