Tuesday, May 28, 2013

stockticker (flask/mongodb) on Heroku

Creating an App

1. Create ~/.gitconfig (if not already there)

$ git config --global user.name "My Name"
$ git config --global user.email emailname@mailhost.com

2. Set-up Project Specific Development environment:

$ mkdir ~/dev/stock-fh
$ virtualenv venv
$ work stock-fh
$ git init
$ gedit .gitignore
$ gedit README.md
$ git add .
$ git commit -m "initial commit"
$ mkdir static static/css static/js static/img static/ico templates

create favicon.ico file at favicon.cc and add to static/ico

add any necessary css, js, and img files, html goes in templates dir


3. Go to bitbucket.org and create a new repo called stock.fh and then:

$ git remote add origin ssh://git@bitbucket.org/gbiglow/stock-fh.git
$ git push -u origin --all

4. install required python components and generate requirements.txt

$ pip install flask
$ pip freeze > requirements.txt
$ git add requirements.txt
$ git commit -m "added initial requirements.txt"
git push origin master

5. create a Procfile for heroku and foreman

$ echo "web: python app.py" > Procfile
$ git add Procfile
$ git commit -m "added initial Procfile"
$ git push origin master

6. Create heroku app (this also creates a heroku remote for git)

$ heroku create stock-fh
git push heroku master

7. use mongoDB on heroku




todo:
  • pip add pymongo etc. update requirements.txt
  • twitter bootstrap
  • investigate flask app generator. code. (possible automation of steps 2-6 above into a single command. hmm...

Notes:
  • This is all based on this great article.
  • The command 'work' (above) is a local script to activate a virtualenv
  • I use bitbucket rather than github as bitbucket has unlimited private repos as part of a free account.









No comments:

Post a Comment