A set of command line tools that help you scaffold out your flask application quickly.
Project description
Flask-Commands
Flask-Commands is a local-first CLI tool that scaffolds Flask projects and keeps generating views, routes, controllers, and models for you so you can stay in flow. This is still very much in a beta stage, so try it out at your own risk.
Getting Started
Flask-Commands bundles a few opinionated conveniences:
flask newbootstraps a ready-to-run Flask project with virtualenv, dotenv, Tailwind wiring, and optional SQLite + migrations (prompted unless you pass--db/--no-db).flask make:viewgenerates HTML views and can optionally add controllers, routes/blueprints, and SQLAlchemy models.flask make:controllerscaffolds a controller class and registers it inapp/controllers/__init__.py.
All generated code is plain Flask with no hidden runtime layers; every file is created on disk. The goal is to remove the repetitive setup work while keeping everything local and transparent.
Installation
Flask-Commands is designed to be installed globally so you can create new Flask apps anywhere on your machine.
pip install Flask-Commands
The published console script is
flask. If you have a clash with Flask’s own CLI, run withpython -m flask_commands.cli ...or rename the script inpyproject.toml.
Quick Start
flask new myproject # prompts for SQLite; use --db/--no-db to skip the prompt
cd myproject
Recommended (macOS):
./run.sh
Manual startup:
source venv/bin/activate
flask run --debug
run.sh opens a Flask shell, starts the dev server, rebuilds tailwind.css and tailwind.min.css, opens VS Code and Safari, and hot-reloads changes in templates/, controllers/, forms/, models/, and routes/.
Add a first page with controller and route wiring:
flask make:view posts.index -cr
flask make:view admin.users.show -cr # nested example
Tailwind is installed automatically when npm is available; otherwise the tool skips it with a warning.
Commands
flask new
After installing Flask-Commands globally, you'll have access to a new command called flask, which lets you quickly scaffold Flask applications from the terminal.
flask new myproject
Once the command completes, you'll see a new directory called myproject/ that contains everything you need to get a Flask application up and running.
If you do not pass --db or --no-db, the command prompts you to include a SQLite database (default yes).
What you get:
- A Python virtual environment
venv/with core Flask dependencies pre-installed and listed inrequirements.txt. - When using
--db(enabled by default unless--no-dbis specified), the following are also included:- Flask-Migrate
- Flask-SQLAlchemy
- A seeded SQLite database with a users table
- An initial migration already applied
- A blueprint-based application skeleton under
app/, organized by responsibility:- Model
app/models/defining all your application’s data models/structure along with their methods. - View
app/templates/containing all HTML templates (including macros/components) used by the application. - Controller
app/controllers/housing controller classes responsible for the logic to gather and serve the requested data. - URL
app/routes/declaring URL paths and connecting them to controllers.
- Model
- The project entry point at
run.py. - Centralized configuration files under
config/. - If
npmis installed, a Tailwind-ready static asset pipeline atapp/static/src/, including npm scripts for watching and building CSS. - Environment configuration files:
.env.env.example
- A default blueprint named
mains, defined inapp/__init__.py:- Routes at
app/routes/mains - A controller at
app/controllers/main_controllernamedMainController - A starter “Hello World” template at
app/templates/mains/index.html
- Routes at
- A macOS-friendly helper script
run.shfor starting the application with a single command:
./run.sh
You can review this structure directly in the Flask-Commands source under flask_commands/project.
flask make:view
Generates template files under app/templates/ from dotted paths (for example, posts.index maps to app/templates/posts/index.html). Optional flags wire up matching components:
-c/--generate-controlleror--controller NAMEcreates or extends the controller class.-r/--generate-routeor--route PATHadds blueprint routes and supports RESTful actions (index,show,create,store,edit,update,destroy, ordelete).-m/--generate-modelor--model NAMEseeds a SQLAlchemy model withid,created_at, andupdated_atcolumns plus an import stub.
Examples:
flask make:view button # view-only snippet
flask make:view components.buttons # reusable component template
flask make:view posts.index -crm # view + controller + route + model
flask make:view recipes.comments.index -rcm # nested relationship
flask make:view posts.show --route '/posts/<int:post_id>' --controller PostController
flask make:controller
Creates a controller class under app/controllers/ and registers it in app/controllers/__init__.py.
flask make:controller PostController
This creates app/controllers/post_controller.py with a class stub:
class PostController:
pass
Use --crud to scaffold all seven RESTful actions, routes/blueprints, and matching templates.
flask make:controller PostController --crud
With --crud, app/controllers/post_controller.py looks like:
from flask import render_template
from flask import redirect, url_for
class PostController:
@staticmethod
def index() -> str:
return render_template('posts/index.html')
@staticmethod
def show(post_id: int) -> str:
return render_template('posts/show.html')
@staticmethod
def create() -> str:
return render_template('posts/create.html')
@staticmethod
def store() -> str:
return redirect(url_for('posts.index'))
@staticmethod
def edit(post_id: int) -> str:
return render_template('posts/edit.html')
@staticmethod
def update(post_id: int) -> str:
return redirect(url_for('posts.index'))
@staticmethod
def destroy(post_id: int) -> str:
return redirect(url_for('posts.index'))
It also generates and wires up routes and templates:
from app.controllers import PostController
from app.routes.posts import bp
@bp.route('/posts', methods=['GET'])
def index():
return PostController.index()
@bp.route('/posts/<int:post_id>', methods=['GET'])
def show(post_id: int):
return PostController.show(post_id)
@bp.route('/posts/create', methods=['GET'])
def create():
return PostController.create()
@bp.route('/posts', methods=['POST'])
def store():
return PostController.store()
@bp.route('/posts/<int:post_id>/edit', methods=['GET'])
def edit(post_id: int):
return PostController.edit(post_id)
@bp.route('/posts/<int:post_id>', methods=['POST'])
def update(post_id: int):
return PostController.update(post_id)
@bp.route('/posts/<int:post_id>/delete', methods=['POST'])
def destroy(post_id: int):
return PostController.destroy(post_id)
And creates four view templates under app/templates/posts/: index.html, show.html, create.html, edit.html.
Contributing
I’m keeping development closed for now, but feedback is welcome. Please open an issue for bugs or ideas. License: MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_commands-0.2.1.tar.gz.
File metadata
- Download URL: flask_commands-0.2.1.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd6b0d2241daab18b9d4fafe0814ba55f4e7e468c9b78e8d1ae1f615ba7d690a
|
|
| MD5 |
a4df3b5087f3d88836dbdb3196de2900
|
|
| BLAKE2b-256 |
7f7af6734dd7fbd3dcd97b2862125e03892103526636203d6db9a1f25e3ea45f
|
Provenance
The following attestation bundles were made for flask_commands-0.2.1.tar.gz:
Publisher:
publish-to-pypi-on-version-change.yml on drewbutcher/flask-commands
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_commands-0.2.1.tar.gz -
Subject digest:
bd6b0d2241daab18b9d4fafe0814ba55f4e7e468c9b78e8d1ae1f615ba7d690a - Sigstore transparency entry: 850004532
- Sigstore integration time:
-
Permalink:
drewbutcher/flask-commands@422e417ff2fe47f28e0ac8dc2a1442c3a1f1aef2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/drewbutcher
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi-on-version-change.yml@422e417ff2fe47f28e0ac8dc2a1442c3a1f1aef2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file flask_commands-0.2.1-py3-none-any.whl.
File metadata
- Download URL: flask_commands-0.2.1-py3-none-any.whl
- Upload date:
- Size: 36.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1453d70dc7d6b768a9b0f709cb73d02af29a9426d4807a58c70f5ae7fe76937c
|
|
| MD5 |
5b3e6d1f90bdc5a245387cf405a94bb8
|
|
| BLAKE2b-256 |
2f0b4d1f44242e2fdba24f426648f3bcf7f083163a0fa493b95a9ec822ace515
|
Provenance
The following attestation bundles were made for flask_commands-0.2.1-py3-none-any.whl:
Publisher:
publish-to-pypi-on-version-change.yml on drewbutcher/flask-commands
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_commands-0.2.1-py3-none-any.whl -
Subject digest:
1453d70dc7d6b768a9b0f709cb73d02af29a9426d4807a58c70f5ae7fe76937c - Sigstore transparency entry: 850004534
- Sigstore integration time:
-
Permalink:
drewbutcher/flask-commands@422e417ff2fe47f28e0ac8dc2a1442c3a1f1aef2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/drewbutcher
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi-on-version-change.yml@422e417ff2fe47f28e0ac8dc2a1442c3a1f1aef2 -
Trigger Event:
push
-
Statement type: