harishvc
harishvc

Reputation: 451

Unable to deploy Python Flask on Heroku

I am not able to deploy Python Flask on Heroku.

Below are entires from the log file

from app import app  
File "/app/app/__init__.py", line 1, in <module>
ImportError: No module named flask
Traceback (most recent call last):
  from flask import Flask
File "RunFlask.py", line 2, in <module>
State changed from starting to crashed
Starting process with command `python RunFlask.py`
Process exited with status 1 Contents of RunFlask.py

Contents

$>cat __init__.py 
from flask import Flask
app = Flask(__name__)
from app import views

$>cat RunFlask.py
import os  
from app import app  
port = int(os.environ.get('PORT', 5000)) 
app.run(debug = True)
print "starting flask server hostname:% port:%" % (host, port)
app.run(host='0.0.0.0', port=port)

Directory Structure

projectdir
 -  RunFlask.py
 - app
      --- __init__.py
      --- views.py
 - requirements.txt   #Flask==0.10.1

Upvotes: 0

Views: 590

Answers (1)

mehdix
mehdix

Reputation: 5154

I assume that you have followed getting started document on Heroku and you have a local repository which corresponds to one Heroku app. According to your directory structure you miss Procfile in the root of your project. Create a file called Procfile and add it to your heroku app:

in your project dir:

echo "web: python RunFlask.py" > Procfile
git add Procfile
git commit -m "adding ProcFile"
git push heroku master
heroku ps:scale web=1
heroku open

Upvotes: 2

Related Questions