Flask project template
contains working example of Flask project with features:
- Ready to ship Flask project template
- Database migrations out-of-the-box migrations (uses Alembic)
- Simple setup
make setup & make run
which make local virtualenv isolated environment and doesn't trash your system python. - Contains
Dockerfile
that allow to setup full linux environment on any host OS supported by Docker - Static files managed by
bower
. By default templates usesBootstrap
but doesn't force you to use this UI framework. - Have working example of GitHub OAuth authorization, you only need to provide your own security and secret key (will work with example keys only on
localhost:5000
). Allow user login/logout - i18n via integrated Babel support and special support targets for
make
- User settings page with ability to switch site language
Flask-FlatPages
support to simplify static pages management- Builtin
Flask-Script
support with shell - Fixtures sump/restore support
Follow this steps:
- Fork project
- Download/clone your own copy
- Run
make setup
- Run
make init
to create sqlite database file make run
, you have working site- Open browser http://127.0.0.1:5000/
- Customize project files and have fun
You can simple run project inside of Docker container or on your prefered environment. If you want to run on your own environment you need:
- Recent python supported version with sqlite library (usually it is included)
- Working
virtualenv-2.7
command, name can vary, so you can change it insideMakefile
make
bower
, if you already havenode.js
withnpm
then run this command:
npm install -g bower
Flask
&Werkzeug
— base for everythingBabel
&Flask-Babel
— i18n supportFlask-FlatPages
withMarkdown
— to maintain auxiliary pages (About, Contacts, etc)Flask-Script
— simplify management tasksFlask-WTF
— form validationflask-restless
— various APIFlask-SQLAlchemy
— database ORM layerflask-migrate
— database schema migration supportpython_social_auth
&Flask-Login
— social networks login
There is several usefull targets in Makefile
:
setup
— will make local virtualenv environment and install all dependencies including JavaScript libraries instatic
folderrun
— local run server in DEBUG modeinit
— synchronize database scheme and apply migrations. This target should be idempotent (if you run in several times you will get the same results in the end), but if you work with several database at once sometimes in need manual tuning.babel
andlazybabel
— generateproject/translations/messages.pot
file with different strategy.addlang
— add new language translation with code taken from shell variableLANG
. Simple usage example$ LANG=en make addlang
updlang
— update language files in language folders made byaddlang
command.
Translation workflow in nutshell:
- Edit templates and py files
- Run
lazybabel
if new translations strings were added or modified - Run
updlang
to apply master.pot
files changes to.po
language files - Run
addlang
if you need to support another language - Update
project/config.py
LANGUAGES
dict to allow users see new translations in Settings page - Use Poedit to translate strings
TBD
TBD