A set of command line tools that help you scaffold out your flask application quickly.
Project description
flask-commands
Local-first CLI that scaffolds a Flask project (venv, dotenv, Tailwind build scripts, blueprints, optional SQLite) and can keep generating views, routes, controllers, and models for you.
Install
- Python 3.10+
- Optional:
npmif you want Tailwind auto-installed; the tool will skip Tailwind ifnpmis missing. pip install Flask-Commands
The published console script is currently
flask. If you have a clash with Flask’s own CLI, run withpython -m flask_commands.cli ...or rename the script toflask-commandsinpyproject.toml.
Commands at a glance
flask new <project_name> [--db/--no-db]— bootstrap a new project in a sibling folder, create a venv, install deps, copy the template, wire Tailwind, and optionally initialize SQLite + migrations.flask make:view <dotted_path_with_name> [options]— create a view underapp/templates/and optionally add a controller method, route/blueprint, and model.
Creating a project: flask new
What happens:
- Creates
<project_name>/and a virtual environment undervenv/. - Installs Python deps: always
Flask+python-dotenv; addsFlask-Login,Flask-Migrate, andFlask-SQLAlchemywhen--db(or when you accept the prompt). - Freezes
requirements.txtfrom the venv. - Copies the starter app from
flask_commands/project(blueprint-based app with configs, sample controller/route, Tailwind input.css,.envfiles,run.py, andrun.sh), and marksrun.shexecutable. - Installs Tailwind via npm and adds
watch:css/build:cssscripts (skipped with a warning if npm is absent). - If
--dbis enabled, runsflask db init/migrate/upgradeusing the new venv to seed SQLite.
Quickstart:
flask new myproject # use --no-db to skip SQLite setup
cd myproject
source venv/bin/activate
flask run --debug # or ./run.sh on macOS to open terminals + Safari and tailwind watchers
run.sh uses osascript/fswatch, so it is macOS-only.
Generating views/routes/controllers/models: flask make:view
Usage:
flask make:view <dotted_path_with_name> [--controller NAME|-c] [--route PATH|-r] [--model NAME|-m]
dotted_path_with_namemaps folders + filename underapp/templates/:posts.index→app/templates/posts/index.html. Nest as needed:admin.users.show→app/templates/admin/users/show.html.- Without flags you get just the view file (a small HTML snippet with a random Python quote).
-c/--generate-controllerinfers a controller class from the path (e.g.,PostControllerfromposts.index) and adds the action method;--controllerlets you set it explicitly.-r/--generate-routeinfers a RESTful route path (CRUD actions get GET/POST as appropriate, nested resources pick up parent IDs if a matching model import exists inapp/models/__init__.py);--routelets you set a path yourself. If the route folder exists, it appends a function; otherwise it creates a blueprint folder and registers it inapp/__init__.py.-m/--generate-modelinfers a singular class name and creates a basic SQLAlchemy model file and import stub;--modellets you name it explicitly.
Examples:
- Minimal view component:
flask make:view button - CRUD start with inferred pieces:
flask make:view posts.index -crm - Nested resource with route params:
flask make:view admin.posts.comments.show -cr - Explicit wiring:
flask make:view posts.show --controller PostController --route /posts/<int:post_id> --model Post
Project template (copied by flask new)
- Application entrypoints:
run.py,run.sh - App package:
app/__init__.pywith blueprint registration + extensions (LoginManager,SQLAlchemy,Migrate) - Default blueprint:
app/routes/mains→app/controllers/main_controller.py→app/templates/mains/index.html - Configs:
config/{base,development,production}_config.py - Static/Tailwind:
app/static/src/input.css(Tailwind CLI buildstailwind.css/tailwind.min.css) - Environment files:
.env,.env.example
Contributing
PRs and issues welcome. 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.1.0.tar.gz.
File metadata
- Download URL: flask_commands-0.1.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.14.0 Darwin/20.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3713fc3a0892a0284e38300cfcc6508c0031a4b7174df856d16da60809836e64
|
|
| MD5 |
1112f98bf5cf4da4b0be2a3b57adf5e8
|
|
| BLAKE2b-256 |
1c04f301bc749bcc62c6114971256f6cd09ebf03c4748801cde7f39fa881f292
|
File details
Details for the file flask_commands-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flask_commands-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.14.0 Darwin/20.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20e439cc22dfd4742e2ba3bdeb0fd7d262c40a01f11226b7bee77354d4361937
|
|
| MD5 |
869986c7acea54c012bcce3d3aff0a18
|
|
| BLAKE2b-256 |
4bab992ca190799a354945463553761de92a124a7552b3a50b58529852c99d3b
|