Skip to content

fullstackpython/flask-base

Repository files navigation

flask-base Circle CI Stories in Ready Code Climate Test Coverage Issue Count

Synopsis

A Flask application template with the boilerplate code already done for you.

Documentation available at http://hack4impact.github.io/flask-base.

What's included?

  • Blueprints
  • User and permissions management
  • Flask-SQLAlchemy for databases
  • Flask-WTF for forms
  • Flask-Assets for asset management and SCSS compilation
  • Flask-Mail for sending emails
  • gzip compression
  • gulp autoreload for quick static page debugging

Extensions

Other branches include even more features

  • admin-edit-static-pages: allow administrators to edit static pages using the ckeditor WYSIWYG editor

Setting up

Clone the repo
$ git clone https://github.com/hack4impact/flask-base.git
$ cd flask-base
Initialize a virtualenv
$ pip install virtualenv
$ virtualenv env
$ source env/bin/activate
(If you're on a mac) Make sure xcode tools are installed
$ xcode-select --install
Add Environment Variables

Create a file called .env that contains environment variables in the following syntax: ENVIRONMENT_VARIABLE=value. For example, the mailing environment variables can be set as the following

MAIL_USERNAME=example@domain.com
MAIL_PASSWORD=SuperSecretPassword
SECRET_KEY=SuperRandomStringToBeUsedForEncryption

Note: do not include the .env file in any commits. This should remain private.

Install the dependencies
$ pip install -r requirements/common.txt
$ pip install -r requirements/dev.txt
Other dependencies for running locally

You need to install Foreman and Redis. Chances are, these commands will work:

$ gem install foreman

Mac (using homebrew):

$ brew install redis

Linux:

$ sudo apt-get install redis-server
Create the database
$ python manage.py recreate_db
Other setup (e.g. creating roles in database)
$ python manage.py setup_dev

Note that this will create an admin user with email and password specified by the ADMIN_EMAIL and ADMIN_PASSWORD config variables. If not specified, they are both flask-base-admin@example.com and password respectively.

[Optional] Add fake data to the database
$ python manage.py add_fake_data

Running the app

$ source env/bin/activate
$ foreman start -f Local

Formatting code

Before you submit changes to flask-base, you may want to auto format your code with python manage.py format.

Project Structure

├── Procfile
├── README.md
├── app
│   ├── __init__.py
│   ├── account
│   │   ├── __init__.py
│   │   ├── forms.py
│   │   └── views.py
│   ├── admin
│   │   ├── __init__.py
│   │   ├── forms.py
│   │   └── views.py
│   ├── assets
│   │   ├── scripts
│   │   │   ├── app.js
│   │   │   └── vendor
│   │   │       ├── jquery.min.js
│   │   │       ├── semantic.min.js
│   │   │       └── tablesort.min.js
│   │   └── styles
│   │       ├── app.scss
│   │       └── vendor
│   │           └── semantic.min.css
│   ├── assets.py
│   ├── decorators.py
│   ├── email.py
│   ├── main
│   │   ├── __init__.py
│   │   ├── errors.py
│   │   ├── forms.py
│   │   └── views.py
│   ├── models.py
│   ├── static
│   │   ├── fonts
│   │   │   └── vendor
│   │   ├── images
│   │   └── styles
│   │       └── app.css
│   ├── templates
│   │   ├── account
│   │   │   ├── email
│   │   │   ├── login.html
│   │   │   ├── manage.html
│   │   │   ├── register.html
│   │   │   ├── reset_password.html
│   │   │   └── unconfirmed.html
│   │   ├── admin
│   │   │   ├── index.html
│   │   │   ├── manage_user.html
│   │   │   ├── new_user.html
│   │   │   └── registered_users.html
│   │   ├── errors
│   │   ├── layouts
│   │   │   └── base.html
│   │   ├── macros
│   │   │   ├── form_macros.html
│   │   │   └── nav_macros.html
│   │   ├── main
│   │   │   └── index.html
│   │   └── partials
│   │       ├── _flashes.html
│   │       └── _head.html
│   └── utils.py
├── config.py
├── manage.py
├── requirements
│   ├── common.txt
│   └── dev.txt
└── tests
    ├── test_basics.py
    └── test_user_model.py

Contributing

Contributions are welcome! Check out our Waffle board which automatically syncs with this project's GitHub issues. Please refer to our Code of Conduct for more information.

Documentation Changes

To make changes to the documentation refer to the Mkdocs documentation for setup.

To create a new documentation page, add a file to the docs/ directory and edit mkdocs.yml to reference the file.

When the new files are merged into master and pushed to github. Run mkdocs gh-deploy to update the online documentation.

License

MIT License

About

A simple Flask boilerplate app with SQLAlchemy, Redis, User Authentication, and more.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 45.3%
  • HTML 40.5%
  • JavaScript 8.8%
  • CSS 5.4%