flaskapp
flaskapp copied to clipboard
Flask Seed App
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 [email protected]: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.
-
Install dependencies
$ cd /path/to/flaskapp $ pip install -r requirements.txt -
Setup a SQLite database for development (
app.db)$ python scripts/create_db.py -
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="[email protected]" 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 -
Run development server
$ python wsgi.pyView at http://127.0.0.1:5000
-
Frontend build scripts
Install node dependencies:
$ cd /path/to/flaskapp/static-src $ npm installRun 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.