Skip to content

kubetail-org/flaskapp

Repository files navigation

Flask Seed App

This app is meant to serve as template for new projects. It has the following features:

  • User accounts implemented with SQLite, cookies and Flask-Login
  • Passwords hashed with bcrypt
  • CSRF protection with Flask-CSRF
  • Email with Flask-Mail
  • Login/logout/forgot password workflow
  • Static asset build step with gulp
  • Basic HTML Web and Email templates with MUI (https://www.muicss.com)
  • Unittests

To create a new app from flaskapp first clone the repository and remove the .git directory:

$ git clone git@github.com:muicss/flaskapp.git
$ rm -rf flaskapp/.git

Then, do a search-replace on the string flaskapp (remember to replace <name> with your app's name):

$ find flaskapp -type f | xargs sed -i'' -e 's/flaskapp/<name>/g'
$ find flaskapp -type f | xargs sed -i'' -e 's/Flaskapp/<Name>/g'
$ mv flaskapp <name>
$ mv <name>/flaskapp <name>/<name>

Now you have your own flask seed project.

Config Variables

flaskapp can be configured using the following environment variables:

Name Description Default Required
DEBUG Flask debug variable "False" no
SECRET_KEY Flask cookie encryption key null yes
MAIL_PORT SMTP port null yes
MAIL_SERVER SMTP hostname null yes
MAIL_USERNAME SMTP username null yes
MAIL_PASSWORD SMTP password null yes

Quickstart

To work in a sandboxed Python environment we recommend installing the app in a Python virtualenv.

  1. Install dependencies

    $ cd /path/to/flaskapp
    $ pip install -r requirements.txt
  2. Setup a SQLite database for development (app.db)

    $ python scripts/create_db.py
  3. Environment variables

    In order to configure flaskapp it is recommended that you create an environment file with the required variables listed above:

    #!/bin/bash
    # Environment variables for Flask seed app
    
    export DEBUG="True"
    export SECRET_KEY="replaceme"
    export MAIL_PORT="587"
    export MAIL_SERVER="mail.google.com"
    export MAIL_USERNAME="user@example.com"
    export MAIL_PASSWORD="replaceme"

    To add the variables to your environment you can source the file as part of your normal workflow:

    $ source /path/to/env-vars.sh
  4. Run development server

    $ python wsgi.py

    View at http://127.0.0.1:5000

  5. Frontend build scripts

    Install node dependencies:

    $ cd /path/to/flaskapp/static-src
    $ npm install

    Run gulp:

    $ npm run build

Unittests

To run all tests:

$ nosetests

To run an individual test:

$ nosetests tests/views/test_content.py

Contribute

Contributions are welcome! If you'd like to report an issue or submit a pull request please use our github page: https://github.com/muicss/flaskapp.