Home > SeeClickMural

SeeClickMural

SeeClickMural is a project mainly written in JAVASCRIPT and PYTHON, it's free.

Quick mashup of See Click Fix graffiti reports & City-sanctioned murals.

Flask Heroku


         ##

######### ###

# ## :GG DG

## :EE EE ;E

## :EE KK ;E

## :EE ;E

# ## #### #### :EEEEEEG KEEEE WE WEEE; ;E EE EE EE

## ## #f # # :EE EE GEf;tEK EEKK EEfiEE, ;E fE EE EE

# ## #l ## EE KE tE EK E; EE ;E E, EE EE

## ##a ### EK EEEEEEE EK E KE ;EEEE EE EE

## ## #s ### EK EE EK E KE ;E EE EE EE

## ## #k ## E EE EE EK E, EK ;E KE EE EE

## ## ##W # #: E EK ;EK.,EK EK EE,:EE, ;E ED KE.,EEE

##### ### W# ####, EK ,KEEE K# DEEK. iK WK KEEE.
                github.com/zachwill/flask_heroku

What is this?

A template to get your Flask app running on heroku as fast as possible. For added convenience, the templates use Twitter's Bootstrap project to help reduce the amount of time it's takes you as a developer to go from an idea to a working site.

All of the CSS stylesheets are written using the Less CSS syntax (even Bootstrap's CSS). If you're using Mac OS X for development, make sure to check out incident57's Less.app.

Alternatively, there's a Less binary compiler that works similarly on the commandline, or you can always use the less.js script in your website otherwise -- it's incredibly fast. For instance, if you visit the Less CSS site, notice that it doesn't link to any CSS files. NOTE: You can hotlink the minified less.js from CDN JS.

Lastly, in heroku's production environment, your Flask application will be served through the gevent Python module WSGI server.

Why should I use this?

Everything I've learned from writing and maintaining the Flask Engine template for Google App Engine has made its way into this repo, too. The goal is to make a simple repo that can be cloned and added to for the majority of projects going forward, while also staying minimal in size and complexity.

Instructions

First, you'll need to clone the repo.

$ git clone [email protected]:zachwill/flask_heroku.git
$ cd flask_heroku

Second, let's download pip, virtualenv, and the heroku Ruby gem.

$ sudo easy_install pip
$ sudo pip install virtualenv
$ gem install heroku

Next, we'll need to install libevent for the gevent production server. If you're operating on a Linux OS, you can apt-get install libevent-dev. If you're using Mac OS X, consider installing the homebrew package manager, and run the following command:

$ brew install libevent

Now, you can setup an isolated environment with virtualenv.

$ virtualenv --no-site-packages env
$ source env/bin/activate

Then, let's get the requirements installed in your isolated test environment.

$ pip install -r requirements.txt

Now, you can run the application locally.

$ python bootstrap.py

Or, to test the production configuration, simply run:

$ python bootstrap.py --gevent

You can also specify what port you'd prefer to use.

$ python bootstrap.py 5555

If you haven't signed up for heroku, go ahead and do that. You should then be able to add your SSH key to heroku, and also heroku login from the commandline.

Now, to upload your application, you'll first need to do the following -- and obviously change app_name to the name of your application:

$ heroku create app_name --stack cedar
$ git push heroku master
$ heroku scale web=1

Finally, we can make sure the application is up and running.

$ heroku ps

Now, we can view the application in our web browser.

$ heroku open

And, to deactivate virtualenv (once you've finished coding), you simply run the following command:

$ deactivate

Next Steps

After you've got your application up and running, there a couple next steps you should consider following.

  1. Create a new README.md file.
  2. Add your Google Analytics ID to the base.html template.
  3. Adjust the author and description <meta> tags in the base.html template.
  4. Change the humans.txt and favicon.ico files in the static directory.
  5. Change the apple-touch icons in the static directory.

Reactivating the Virtual Environment

If you haven't worked with virtualenv before, you'll need to reactivate the environment everytime you close or reload your terminal.

$ source env/bin/activate

If you don't reactivate the environment, then you'll probably receive a screen full of errors when trying to run the application locally.

Adding Requirements

In the course of creating your application, you may find yourself installing various Python modules with pip -- in which case you'll need to update the requirements.txt file. One way that this can be done is with pip freeze.

$ pip freeze > requirements.txt

Renaming Your Heroku App

Renaming your application is incredibly easy.

$ heroku rename new_name

If your account is verified -- and your credit card is on file -- you can also easily add a custom domain to your application.

$ heroku addons:add custom_domains
$ heroku domains:add www.mydomainname.com

You can add a naked domain name, too.