Fbone (Flask bone) is a Flask (Python microframework) template/bootstrap/boilerplate application, with best practices.
You can use it for
- learning Flask.
- kicking off your new project faster.
- Handle orm with SQLAlchemy.
- Handle web forms with WTForms.
- Implement user session management (signin/signout/rememberme) with Flask-Login.
- Implement reset password via email with Flask-Mail.
- Implement unit testing with Flask-Testing.
- Implement external script (initdb/testing/etc) with Flask-Script.
- Handle i18n with Flask-Babel.
- Well designed structure for large project.
- Quickly Deploy via mod_wsgi and fabric.
- Admin interface.
- Home-bake logger.
Pre-required:
- Ubuntu (should be fine in other linux distro)
- git
- pip
- fabric
- sqlite
- virtualenv
- apache + mod_wsgi
Clone.
git clone https://github.com/imwilsonxu/fbone.git fbone
virtualenv.
fab setup
Debug.
fab d
Open http://127.0.0.1:5000, done!
Clone.
cd /var/www
git clone https://github.com/imwilsonxu/fbone.git fbone
sudo chown `whoami` -R fbone
vhost.
WSGIDaemonProcess fbone user=wilson group=wilson threads=5
WSGIScriptAlias /fbone /var/www/fbone/app.wsgi
<Directory /var/www/fbone/>
WSGIScriptReloading On
WSGIProcessGroup fbone
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
virtualenv.
fab setup
IMPORTANT:
- Change
INSTANCE_FOLDER_PATHinfbone/utils.pyto suit yourself. - Put
production.cfgunderINSTANCE_FOLDER_PATH.
βββ app.wsgi (mod_wsgi wsgi config)
βββ CHANGES
βββ fabfile.py (fabric file)
βββ fbone (main app)
βΒ Β βββ api (api module)
βΒ Β βββ app.py (create flask app)
βΒ Β βββ config.py (config module)
βΒ Β βββ decorators.py
βΒ Β βββ extensions.py (init flask extensions)
βΒ Β βββ frontend (frontend module)
βΒ Β βββ __init__.py
βΒ Β βββ settings (settings module)
βΒ Β βββ static
βΒ Β βΒ Β βββ css
βΒ Β βΒ Β βββ favicon.png
βΒ Β βΒ Β βββ humans.txt
βΒ Β βΒ Β βββ img
βΒ Β βΒ Β βββ js
βΒ Β βΒ Β βββ robots.txt
βΒ Β βββ templates
βΒ Β βΒ Β βββ errors
βΒ Β βΒ Β βββ frontend
βΒ Β βΒ Β βββ index.html
βΒ Β βΒ Β βββ layouts
βΒ Β βΒ Β βββ macros
βΒ Β βΒ Β βββ settings
βΒ Β βΒ Β βββ user
βΒ Β βββ translations (i18n)
βΒ Β βββ user (user module)
βΒ Β βΒ Β βββ constants.py
βΒ Β βΒ Β βββ forms.py (wtforms)
βΒ Β βΒ Β βββ __init__.py
βΒ Β βΒ Β βββ models.py
βΒ Β βΒ Β βββ views.py
βΒ Β βββ utils.py
βββ LICENSE
βββ manage.py (manage via flask-script)
βββ MANIFEST.in
βββ README.markdown
βββ screenshots
βββ setup.py
βββ tests (unit tests, run via `nosetest`)
Thanks to Python, Flask, its extensions, and other goodies.
