Awesome
generator-flask-app
Yeoman Generator for modern web applications using flask.
Features
- Flask Application infrastructure;
- Flask Script support;
- Templates with Layout pre-configured;
- Flask Debug Toolbar support;
- OAuth Authentication with Google, Facebook, Github and Twitter support;
- MongoEngine models with User example;
- SQLAlchemy models with User example;
- Coffeescript and Compass/scss static support with auto-reload;
- Bower support;
- Automatic spriting via compass;
- Alembic Migrations;
- Flask Admin with automatic panels for mongoengine and sqlalchemy;
- Resque(PyRes) queueing support;
- Celery queueing support (still not implemented);
- Travis continuous integration support (still not implemented);
- Heroku application deployment support (still not implemented).
Installing
To install flask-app generator, run:
$ npm install -g generator-flask-app
Usage
Creating your app is as easy as:
$ yo flask-app
Just make sure you are already inside the directory for your new application. Just follow the questions and you'll have an application running in a moment;
Running My App
Before starting, make sure you have:
- A VirtualEnv (or similar) set-up for the new environment;
- A ruby environment with an interpreter version compatible with Sass/Compass;
- Node.js correctly installed.
To setup all the dependencies for your project, run make setup
.
After all the dependencies have been installed, you should be able to run your application with make run
. Your application will be running in port 3000.
If you selected oauth application, make sure you use the host http://local.generator.com:3000/ or change the authorization providers to your own application.
If you have selected sqlalchemy support, you probable need to create the database before running with make db
.
Running tests
To run your application tests, just run make test
.
Application usage
General commands
- "make list" to list all available targets;
- "make setup" to install all dependencies (do not forget to create a virtualenv first);
- "make test" to test your application (tests in the tests/ directory);
Redis commands
- "make redis" to get a redis instance up (localhost:4444);
- "make kill-redis" to kill this redis instance (localhost:4444);
- "make redis-test" to get a redis instance up for your unit tests (localhost:4448);
- "make kill-redis-test" to kill the test redis instance (localhost:4448);
- "make tox" to run tests against all supported python versions.
Using Flask Admin
- Just access http://local.generator.com:3000/admin/;
- In order to access the admin you must change your local.conf file to change the AUTHORIZED_ADMINS configuration to include the e-mail you are logging with;
SQL Alchemy commands
- "make migration DESC="<description of the migration>"" to create a new database migration;
- "make auto_migration DESC="<description of the migration>"" to create a new database migration automatically from changes in the model;
- "make db" to create the database and run migrations;
- "make data" to run migrations; IMPORTANT: Do not forget to update configuration (local.conf and other environments) with your MySQL (or other database) connection string;
PyRes commands
- "make worker" to run a PyRes Worker;
- "make resweb" to run a web dashboard for PyRes (available at http://127.0.0.1:3001 - user: admin, pass: 123);
In order to use pyres, you must specify the queues to listen on. This can be done by setting the DEFAULT_QUEUES configuration or by running workers with "-q queue1,queue2";
IMPORTANT: Do not forget to update configuration (local.conf and other environments) with your redis connection string and change the resweb user and password;
Contributing
Please fork, update what you need and pull request.