Coder Social home page Coder Social logo

flask_heroku's Introduction

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.

Lastly, in Heroku's production environment, your Flask application will be served through gunicorn and gevent.

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, foreman, and the heroku Ruby gem.

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

Now, you can setup an isolated environment with virtualenv.

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

Installing Packages

Gevent

To use gevent, 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

If you're using Mac OS X, you can also install libevent through a DMG available on Rudix.

Without Gevent

If you'd rather use gunicorn without gevent, you just need to edit the Procfile and requirements.txt.

First, edit the Procfile to look the following:

web: gunicorn -w 4 -b "0.0.0.0:$PORT" app:app

Second, remove gevent from the requirements.txt file.

pip

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

$ pip install -r requirements.txt

Running Your Application

Now, you can run the application locally.

$ foreman start

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

$ foreman start -p 5555

Deploying

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 -s cedar

And, then you can push your application up to Heroku.

$ 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

Custom Domains

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.

$ heroku domains:add mydomainname.com

Lastly, add the following A records to your DNS management tool.

75.101.163.44
75.101.145.87
174.129.212.2

flask_heroku's People

Contributors

magnusp avatar ncrazed avatar philfreo avatar pmrowla avatar zachwill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask_heroku's Issues

Heroku git push rejected, No cedar supported app

I tweak the basic flaskr app available in git to test to launch in heroku, i am just beginning to ue heroku so i wanted to test some example app by deploying it This is the error i get

C:\Users\monk\Desktop\flask-master\examples\flaskr>git push heroku master
Counting objects: 935, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (880/880), done.
Writing objects: 100% (935/935), 2.63 MiB | 6 KiB/s, done.
Total 935 (delta 107), reused 0 (delta 0)
! Heroku push rejected, no Cedar-supported app detected

To [email protected]:stark-badlands-6689.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:stark-badlands-6689.git'

I try to follow some of the issues in this guthub as well but no luck for me. i tried pushing it via venv as well but same problem i have done the steps in this issue

#3

but it doesn work for me

the commands

git init && git aa
git ci -am "First commit"

doesn't work in my command prompt as it says

git: 'aa' is not a git command. See 'git --help'.

and

git: 'ci' is not a git command. See 'git --help'.

Did you mean this?
gui

I am getting to frustrated with this heroku and flask already please help.

the olny thing i have changed in original flaskr example is this

import os (at beginning)

port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
at the end of the line

i have also added a proc file
web: python flaskr.py

Use Gunicorn instead

Gunicorn would make the whole bootstrap.py thing unnecessary. It also spins a configured number of workers, and has an incredibly excellent gevent worker type (as well as tornado, if you're into that :).

Just a suggestion :)

first step problem

so when I started at the instructions part, it told me to type in:
git clone [email protected]:zackwill/flask_heroku.git
but when I did that, it says this:
error2
so I am not sure if this is because i forgot a step or if the file has been closed.

gevent requires libevent

I ran through setup and stumbled across some errors on install of gevent.

Turns out you need libevent to run gevent.

apt-get install libevent-dev

This is also simple with homebrew on os x.

brew install libevent

Cheers!

Jack

Heroku push rejected, no Cedar-supported app detected

I'm running on Mac OS X Lion with the latest updates and lib event installed via brew. Everything seems to work fine until I try to deploy, at which point I get the "no Cedar-supported app detected" error, despite the fact that I've done:

heroku create junker --stack cedar

Here's the output from the git push:

(env)Davids-MacBook-Pro:env davidthewatson$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts.
Counting objects: 985, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (925/925), done.
Writing objects: 100% (985/985), 3.94 MiB | 842 KiB/s, done.
Total 985 (delta 57), reused 0 (delta 0)

-----> Heroku receiving push
! Heroku push rejected, no Cedar-supported app detected

To [email protected]:junker.git
! [remote rejected] master -> master (pre-receive hook declined)

error: failed to push some refs to '[email protected]:junker.git'

Thanks,
David

Heroku push rejected, no Cedar-supported app detected

Shai.Cohen@SHAICOHEN-PC ~/.ssh/blooming-wind-6746 (master)
$ git push heroku master
Enter passphrase for key '/c/Users/Shai.Cohen/.ssh/id_rsa':
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (15/15), 2.79 KiB, done.
Total 15 (delta 0), reused 0 (delta 0)

-----> Heroku receiving push
! Heroku push rejected, no Cedar-supported app detected

To [email protected]:growing-planet-4986.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:growing-planet-4986.git'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.