PyWeber CLI¶
The PyWeber Command Line Interface (CLI) provides tools to create, manage, and run PyWeber applications.
Installation¶
The CLI is automatically installed with PyWeber:
Basic Commands¶
Check Version¶
Display the current version of PyWeber:
Update PyWeber¶
Update to the latest version of PyWeber:
Project Management¶
Create a New Project¶
Create a new PyWeber project with the recommended directory structure:
Add the --with-config flag to automatically create a configuration file:
This command creates a new project with the following structure:
my_project/
├── src/
│ ├── assets/
│ │ └── favicon.ico
│ └── style/
│ └── style.css
├── templates/
│ └── index.html
└── main.py
If --with-config is specified, it also creates:
Run a Project¶
Run a PyWeber application:
By default, this command runs the main.py file in the current directory. You can specify a different file:
Hot Reload¶
Enable hot reload during development to automatically refresh the browser when files change:
You can also run with reload mode directly:
This updates the configuration file to set reload_mode to true.
Configuration Management¶
Create Configuration File¶
Create a configuration file for an existing project:
You can specify a custom path and filename:
Edit Configuration¶
Edit the project configuration interactively:
This opens an interactive menu where you can: - Edit existing fields - Remove fields - Remove sections - Add new fields - Add new sections
Add Configuration Section¶
Add a new section to the configuration file:
Dependency Management¶
Install Requirements¶
Install project dependencies defined in the configuration file:
You can specify a custom configuration file path:
Configuration File Format¶
PyWeber uses TOML for configuration files. A typical configuration includes:
[app]
name = "My PyWeber App"
description = "A PyWeber application"
keywords = ["pyweber", "web", "python"]
icon = "src/assets/favicon.ico"
[server]
host = "localhost"
port = 8800
[session]
reload_mode = false
[websocket]
host = "localhost"
port = 8801
[requirements]
packages = ["requests", "pillow"]
Configuration Types¶
When adding new configuration fields, you can specify types:
| Type | Format Example |
|---|---|
| String | name str Alex |
| Integer | age int 18 |
| Float | price float 19.99 |
| List | tags list python flask api |
| Dictionary | db dict user:str=admin; port:int=5432 |
Example Workflows¶
Create and Run a New Project¶
# Create a new project with configuration
pyweber create-new my_webapp --with-config
# Navigate to the project directory
cd my_webapp
# Run the application with hot reload
pyweber run --reload
Update Configuration and Install Dependencies¶
Customize Project Configuration¶
# Add a new database section
pyweber add-section --section-name database
# Edit configuration to add database settings
pyweber -e
Troubleshooting¶
If you encounter issues with the CLI:
- Ensure you have the latest version of PyWeber installed
- Check that you're in the correct directory
- Verify that your project structure follows PyWeber conventions
- Check the console for error messages