Files
PWF/README.md
2025-11-06 10:55:39 +08:00

85 lines
1.7 KiB
Markdown

# PWF
Plugin-based Web Framework
## Clone
add as submodule
```bash
git init
git submodule add <repository_url> PWF
```
or
```bash
git clone <repository_url> PWF
cd PWF/Convention
git submodule update --init --recursive
```
## First Start
use
```bash
python app.py
# from PWF.Application.app import main
# main()
```
to start and generate **Assets** Folder(generate by [ProjectConfig](Convention/Runtime/GlobalConfig.py))
## Assets
Every default argument define in **Assets/config.json**,
properties in **find** is define the arguments value where you not setting
Sometimes some property not exists in config,
just because program not running to the place where argument been referenced
## Arguments
### Commandline and Config
- **--host** default: 0.0.0.0
- **--port** default: 8000
- **--verbose** default: false
### Only Config
- **max_concurrent_requests** default: 100
- **database_path** file on Assets, default: db.db
- **plugin_dir** where plugins load, default: Plugins
- **always_return_ok** default: true
## Plugins
First import interface and define class
```python
from CoreModules.plugin_interface import PluginInterface, DatabaseModel
class MyPlugin(PluginInterface):
def generate_router_callback(self):
async def callback():
return {"message": "Hello from MyPlugin"}
return callback
def register_db_model(self):
return DatabaseModel(
table_name="my_plugin_table",
column_names=["id", "data", "created_at"],
column_defs={
"id": "INTEGER PRIMARY KEY",
"data": "TEXT",
"created_at": "INTEGER"
}
)
def dependencies(self):
return []
def wake_up(self):
pass
```