Command-Line Interface

JsWeb comes with a powerful command-line interface (CLI) that helps you manage your project, run the development server, and handle database migrations. The main command is jsweb, and it must be run from your project's root directory.

jsweb new <project_name>

This command scaffolds a new JsWeb project, creating a standard directory structure and all the essential files to get you started quickly.

jsweb new my_awesome_app

It generates an app.py, a config.py with a unique secret key, and blueprints for views, authentication, and models, along with templates and static files.


jsweb run

Starts the built-in development server. It dynamically loads your application and configuration from the current directory.

jsweb run

Options:

# Run with auto-reload on port 8080, accessible on the local network
jsweb run --reload --host 0.0.0.0 --port 8080

jsweb db

This is a group of commands for managing your database schema migrations with Alembic. It helps you keep your database structure in sync with your application's models.

jsweb db prepare

Compares your SQLAlchemy models in models.py against the current state of the database and automatically generates a new migration script with the detected changes (e.g., new tables, columns, or modifications).

# After changing your models, run:
jsweb db prepare -m "Add a bio field to the User model"

The command will first check if your database is up-to-date. If not, it will prompt you to run db upgrade first. It also gives you a readable preview of the changes before creating the script.

Options:

jsweb db upgrade

Applies all pending (unapplied) migration scripts to your database, bringing its schema up to the latest version defined by your models.

jsweb db upgrade

You should run this command after creating a new migration with jsweb db prepare or when setting up your application in a new environment to initialize the database schema.