Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a simple python script on heroku without flask/django?

Tags:

python

heroku

I'm trying to run a simple hello world python program on my heroku server. I'm new to heroku.I was able to successfully deploy my script to heroku. My python script and procfile are given below,

hi.py

print("hello world")

Procfile

web: python hi.py

I got "Hello world" as output when i ran heroku run web on my terminal.But when i try to run the app using heroku web url it shows the following error.

Application Error An error occurred in the application and your page could not be served. Please try again in a few moments.

What did i do wrong here? I'm newbie to heroku & its concepts, please do bare.

like image 445
Alfred Francis Avatar asked Feb 16 '16 17:02

Alfred Francis


1 Answers

I disagree and state you want flask

main_app.py

import flask
app = flask.Flask(__name__)

@app.route("/")
def index():
    #do whatevr here...
    return "Hello Heruko"

then change your procfile to web: gunicorn main_app:app --log-file -

like image 137
Joran Beasley Avatar answered Nov 07 '22 03:11

Joran Beasley