Skip to main content

PyScript CLI

A command-line interface for PyScript.

Version Test codecov pre-commit.ci status Checked with mypy

Quickly wrap Python scripts into a HTML template, pre-configured with PyScript.

❯ pyscript

 Usage: pyscript [OPTIONS] COMMAND [ARGS]...

 Command Line Interface for PyScript.

╭─ Options ──────────────────────────────────────────────────────────────────────────────────────╮
│ --version          Show project version and exit.                                              │
│ --help             Show this message and exit.                                                 │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────╮
│ create  Create a new pyscript project with the passed in name, creating a new directory in the │
│         current directory. Alternatively, use `--wrap` so as to embed a python file instead.   │
│ run     Creates a local server to run the app on the path and port specified.                  │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯

Installation

Using Pip

$ pip install pyscript

Installing the developer setup from the a repository clone

see the Developer setup section on CONTRIBUTING page

Usage

run

Spin up a local server to run on the path and specified port

$ pyscript run <path_of_folder>

This will serve the folder path_of_folder at localhost:8000 by default and will open the URL in a browser window. Default is current directory if path_of_folder is not supplied.

To use a different port, use --port option.

$ pyscript run <path_of_folder> --port 9000

To avoid opening a browser window, use --no-view option.

$ pyscript run <path_of_folder> --no-view

create

Create a new pyscript project with the passed in name, creating a new directory

$ pyscript create <name_of_app>

This will create a new directory named name_of_app under the current directory.

The interactive prompts will further ask for information such as description of the app, name of the author, email of the author, etc. These of course can be provided via options such as --author-name etc. Use pyscript create --help for more information.

The following files will be created:

  • index.html: start page for the project
  • pyscript.toml: project metadata and config file
  • main.py: a "Hello world" python starter module

Use --wrap to embed a python file OR a command string

  • Embed a Python script into a PyScript HTML file
$ pyscript create --wrap <filename.py>

This will generate a project i.e. a new directory named filename under the current directory.

Similar to the above, interactive prompts will further ask for metadata information.

The following files will be created:

  • index.html: start page for the project
  • pyscript.toml: project metadata and config file
  • main.py: contains code of filename.py

This can be overridden with the -o or --output option:

$ pyscript create --wrap <filename.py> -o <another_filename.html>

i.e. the HTML file created in the above directory will now be named another_filename.html

  • Very simple command examples with --command option

The -c or --command option can be used to demo very simple cases.

By default, the name of the project folder created will be pyscript-command-app with the HTML file named index.html.

-o/--output option can be used with the -c/--command option to configure name of the project folder as well as the name of the resulting HTML file.

$ pyscript create --wrap -c 'print("Hello World!")' -o <output_filename.html>

This will generate a project i.e. a new directory named output_filename under the current directory.

Similar to the above, interactive prompts will further ask for metadata information.

The following files will be created:

  • output_filename.html: start page for the project
  • pyscript.toml: project metadata and config file
  • main.py: contains code of the command string passed via -c/--command

Metadata

Release files for pyscript 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyscript 0.3.3
File Size Uploaded Provenance
pyscript-0.3.3.tar.gz 20.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyscript 0.3.3
File Interpreter ABI Platform
pyscript-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.3 kB

Release files / pyscript-0.3.3.tar.gz

Download URL pyscript-0.3.3.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
11fc64a3f187d8645c601ae6a80e3f0142e0dd9e0c5d3244b0ec508ca0d373f9
BLAKE2b-256 checksum
How to use checksums
9d4dee8606f71049fe29666e5541f0dd1a4f861dd3a6824334fac3c5aec3e8d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / pyscript-0.3.3-py3-none-any.whl

Download URL pyscript-0.3.3-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
320383f38e9eec6515dbe0c184d4ad9d9c58e2c98fb82ec09e8d8b2e93c9e62f
BLAKE2b-256 checksum
How to use checksums
f2d81881edf3b8653cf2f3b8005704126c738c151b6f8168a5806ea61f1efb5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.5

Security for pyscript 0.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page