Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

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.









Sunday, May 26, 2013

Using Bitbucket with Pycharm

Pycharm (the python IDE) has built in support for Github. That's nice as I want to use git for source code management. Codeschool by the way has a nice free git intro course in their electives area. Enough to get one going with git.

The free Github plan however is restrictive compared to Bitbucket's free plan.

Github: no private repos, limited to just yourself.
Bitbucket: unlimited private repos, up to 5 team members

So how does one configure Pycharm to use Bitbucket?

  1. Create a free bitbucket account
  2. Launch Pycharm and go to Settings->Plugins
  3. Click on Browse Repositories
  4. Enter Bitbucket into the search field
  5. Highlight the Bitbucket pluging and click on the "dowload & install" icon
  6. Close all windows and re-start Pycharm (required after a plug-in installation)
  7. Relauch Pycharm
  8. Return to settings and select the new Bitbucket option in the IDE section
  9. Enter Bitbucket userID and password.
  10. Click on Add SSH Key button and navigate to the SSH key you used for Bitbucket