Command-Line Interface (CLI)
Flaskteroids extends the flask CLI with a powerful set of tools to streamline development.
Generators
Use the flask generate command to create various components:
Migration
Allows generation of database migrations. You can specify different migration commands
depending on what you want to achieve. All tables come by default with an auto-increment
id field, and a created_at date field.
Creating new tables
Example: flask generate migration CreateProducts name:string!
Adding columns to existing table
Example: flask generate migration AddPriceToProducts price:float
Removing columns from an existing table
Example: flask generate migration RemovePriceFromProducts price
Dropping an existing table
Example: flask generate migration DropProducts
Model
This will created together a Model and it's corresponding migration. See Migrations for further details.
Example: flask generate model User name:string email:string
Controller
This will generate:
- A new controller with the actions specified.
- A views for each action.
- Entries in routes file linking all controller actions individually
Example: flask generate controller Users index show
Resource
This will Generate:
- A model and it's migration.
- An empty controller associated to that model.
- A resource entry linking the controller in routes.
All the code is up to be written by you.
Generates a model and a RESTful controller.
Scaffold
This will generate:
- A model and it's migration.
- A controller associated to that model fully supporting CRUD operations.
(The controller will have
index,show,new,edit,create,updateanddestroyactions) - All views backing up CRUD operations
- A resource entry linking the controller in routes.
Generates a model, RESTful controller, and views.
Mailer
Example: flask generate mailer UserMailer welcome_email
Authentication
Sets up a complete authentication system (routes, controllers, views and models for managing users and sessions).
It will add:
- A
Usermodel (email, password_digest). - A
Sessionmodel (user_id, ip_address, user_agent). - Views and Controllers for logging in.
- Views and Controllers for editing passwords
- Views and Mailers for resetting user passwords
- Routes for session and password management