Section 3 : Can you feel me?
Hey you, would you help me to carry the stone? Open your heart, I'm coming home ... Hey you, don't tell me there's no hope at Together we stand, divided we fall
-- PINK FLOYD
I hate to give up and I hate to depend on someone else,
I want to finish the work all by myself according to schedule, but I knew, knew deep down inside where all the serious ,big decisions are made, that that would never happen ...
Since the only alternative to being taken as a loser was to die fighting, I made a seriously decision: to ask @simpleowen help me with my flask app.
Finally I got the app on heroku, thanks to everyone helped me the last weekend.
OK, HERE IS THE SIMPLE 13 STEPS TO FINISH A DEMO APP ON HEROKU:
1 . I will assume you had already (1)created an account at heroku, (2)installed the heroku toolbelt, (3)sign up your heroku account into the terminal, (4)have one flask app.
2 . Copy all the files of your flask app and put them in one new fresh folder, including the app.py(for me, it's web5.py), index.html and other files, make sure you can run the app locally.
3 . ADD the following texts:
(1) requirements.txt(the name has to be attached by ".txt"); Heroku recognizes an app as a Python app by the existence of a "requirements.txt" file in the root directory.
LIST the packages that (what you really need) pip should install for your app; here is mine:
>Flask==0.12
gunicorn==19.6.0
Jinja2==2.9.5
psycopg2==2.6.1
requests==2.9.1
(2) Procfile (the name WITHOUT ".txt")
Use a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start your app.
Define a Procfile, you can follow this -
Define a Procfile
and here is mine:
web: gunicorn web5:app --log-file -
(3) runtime.txt(the name has to be attached by ".txt");
this file will tell the heroku your app is on python 2 or python 3, if you don't set it correctly, it will cause the decode issue.
I deployed the runtime.txt like this:
python-3.6.0
4 . Don't forget to change the code of your main file( .py,which is to start your app) ,the code:"app.run(debug=True) " #should change to be the fllowing code:"app.run() ";
5 . cd the folder which you put all the files of your app;
6 . enter "git init" in the terminal;
7 . enter $ heroku create yourapp
8 . enter $ pip3 install -r requirements.txt(since I had already tried so many time, installed so many commands in my terminal,I am not sure the order is right exactlly, you can try to do it before 7 or ,after 9)
9 . enter $ git add .
10 . enter $ git commit -m 'just for test'
11 . enter $ git push heroku master
12 . enter $ heroku open
DONE!!!
OR, NOT ...
13 . View logs: enter $ heroku logs --tail to see what's going, and then,
TRY AGGIN !!
You will be there one day ~~
The demo I created the first day:
