Boilerplate template for a Python Flask application with Flask-SQLAlchemy, Flask-WTF, Fabric, Coverage, and Bootstrap
Hello. Want to get started with Flask quickly? Good. You came to the right place. This Flask application framework is pre-configured with Flask-SQLAlchemy, Flask-WTF, Fabric, Coverage, and the Bootstrap frontend (among others). This will get your Flask app up and running on Heroku or PythonAnywhere quickly. Use this starter, boilerplate for all you new Flask projects. Cheers!
Designed for the Real Python course.
Preview the skeleton app here - http://www.flaskboilerplate.com/
EXAMPLE APP: http://flasktaskr.herokuapp.com/
What is Flask? Flask is a microframework for Python based on Werkzeug and Jinja2.
├── Procfile
├── Procfile.dev
├── README.md
├── app.py
├── config.py
├── error.log
├── forms.py
├── models.py
├── requirements.txt
├── static
│ ├── css
│ │ ├── bootstrap-3.0.0.min.css
│ │ ├── bootstrap-theme-3.0.0.css
│ │ ├── bootstrap-theme-3.0.0.min.css
│ │ ├── font-awesome-3.2.1.min.css
│ │ ├── layout.forms.css
│ │ ├── layout.main.css
│ │ ├── main.css
│ │ ├── main.quickfix.css
│ │ └── main.responsive.css
│ ├── font
│ │ ├── FontAwesome.otf
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.svg
│ │ ├── fontawesome-webfont.ttf
│ │ └── fontawesome-webfont.woff
│ ├── ico
│ │ ├── apple-touch-icon-114-precomposed.png
│ │ ├── apple-touch-icon-144-precomposed.png
│ │ ├── apple-touch-icon-57-precomposed.png
│ │ ├── apple-touch-icon-72-precomposed.png
│ │ └── favicon.png
│ ├── img
│ └── js
│ ├── libs
│ │ ├── bootstrap-3.0.0.min.js
│ │ ├── jquery-1.10.2.min.js
│ │ ├── modernizr-2.6.2.min.js
│ │ └── respond-1.3.0.min.js
│ ├── plugins.js
│ └── script.js
└── templates
├── errors
│ ├── 404.html
│ └── 500.html
├── forms
│ ├── forgot.html
│ ├── login.html
│ └── register.html
├── layouts
│ ├── form.html
│ └── main.html
└── pages
├── placeholder.about.html
└── placeholder.home.html
$ git clone https://github.com/realpython/flask-boilerplate.git
$ cd flask-boilerplate
$ virtualenv --no-site-packages env
$ source env/bin/activate
$ pip install -r requirements.txt
$ python app.py
heroku login
. Then follow the prompts:Enter your Heroku credentials.
Email: [email protected]
Password (typing will be hidden):
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading ssh public key /Users/michaelherman/.ssh/id_rsa.pub
pip freeze > requirements.txt
. Now, this will only create the dependencies from the libraries you installed using pip. If you used easy_install, you will need to add them directly to the file.web: gunicorn app:app --log-file=-
Then save the file in your applications root or main directory as Procfile (no extension). The word "web" indicates to Heroku that the application will be attached to the HTTP routing stack once deployed.
$ git init
$ git add .
$ git commit -m "initial files"
$ heroku create <name_it_if_you_want>
$ git push heroku master
$ heroku open
You app should look similar to this - http://www.flaskboilerplate.com/
Having problems? Look at the Heroku error log:
$ heroku logs
If you plan on working exclusively within PythonAnywhere, which you can, because it provides a cloud solution for hosting and developing your application, you can skip step one entirely. :)
$ git clone git://github.com/realpython/flask-boilerplate.git
$ cd flask-boilerplate
$ virtualenv venv --no-site-packages
$ source venv/bin/activate
$ pip install -r requirements.txt
activate_this = '/home/your-username/flask-boilerplate/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
from
project_home = u'/home/your-username/mysite'
to
project_home = u'/home/your-username/flask-boilerplate'
from
from flask_app import app as application
to
from app import app as application
Now you're ready to start developing!
Need to PUSH your PythonAnywhere repo to Github?
$ ssh-keygen -t rsa
$ cat ~/.ssh/id_rsa.pub
PUSH and PULL away!
deactivate
source venv/bin/activate
(2) Windows - venv\scripts\activate