2025-11-06 10:55:39 +08:00
|
|
|
# PWF
|
|
|
|
|
|
|
|
|
|
Plugin-based Web Framework
|
2025-11-05 16:21:05 +08:00
|
|
|
|
|
|
|
|
## Clone
|
|
|
|
|
|
2025-11-06 10:55:39 +08:00
|
|
|
add as submodule
|
2025-11-05 16:21:05 +08:00
|
|
|
|
|
|
|
|
```bash
|
2025-11-06 10:55:39 +08:00
|
|
|
git init
|
|
|
|
|
git submodule add <repository_url> PWF
|
2025-11-05 16:21:05 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
|
|
```bash
|
2025-11-06 10:55:39 +08:00
|
|
|
git clone <repository_url> PWF
|
|
|
|
|
cd PWF/Convention
|
2025-11-05 16:21:05 +08:00
|
|
|
git submodule update --init --recursive
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## First Start
|
|
|
|
|
|
|
|
|
|
use
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
python app.py
|
2025-11-06 10:55:39 +08:00
|
|
|
# from PWF.Application.app import main
|
|
|
|
|
# main()
|
2025-11-05 16:21:05 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
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
|
2025-11-06 10:55:39 +08:00
|
|
|
- **database_path** file on Assets, default: db.db
|
2025-11-05 16:21:05 +08:00
|
|
|
- **plugin_dir** where plugins load, default: Plugins
|
2025-11-05 17:27:15 +08:00
|
|
|
- **always_return_ok** default: true
|
2025-11-05 16:21:05 +08:00
|
|
|
|
|
|
|
|
## Plugins
|
|
|
|
|
|
|
|
|
|
First import interface and define class
|
|
|
|
|
```python
|
|
|
|
|
from CoreModules.plugin_interface import PluginInterface, DatabaseModel
|
2025-11-05 16:57:37 +08:00
|
|
|
|
|
|
|
|
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):
|
2025-11-06 10:55:39 +08:00
|
|
|
return []
|
2025-11-05 16:57:37 +08:00
|
|
|
|
|
|
|
|
def wake_up(self):
|
|
|
|
|
pass
|
2025-11-05 16:21:05 +08:00
|
|
|
```
|