✨ 跟项目能跑起来就差这一步!这次狠狠修了一波: 🩺 修复40+损坏Python文件 - 补全所有缺少的class定义头(plugin-loader-pro、code-reviewer、 http-api/ws-api/http-tcp、webui/dashboard/log-terminal 等) - 修复中文括号、字符串未闭合、缩进错乱等语法问题 🔗 创建符号链接 plugin_bridge -> plugin-bridge - 解决Python模块路径不支持连字符的问题 - 关联修复 plugin-bridge 中错误的 import 路径 🧹 清理废弃代码 - 删除 oss/tui/ 目录(已废弃) - 清理所有 __pycache__ 和 .pyc 缓存文件 ✅ 全量语法检查通过,零错误! 📋 ai.md 新增代码审计报告和分阶段修复计划 🗺️ 所有插件 use() 调用现在走统一路径
web-toolkit Web 工具包
提供静态文件服务、模板渲染、路由等 Web 开发工具。
功能
- 静态文件服务:提供 HTML/CSS/JS/图片等静态文件
- 模板引擎:支持变量替换、条件判断、循环
- 路由管理:为 HTTP 和 TCP 服务器注册路由
- 自动首页:自动查找 index.html
使用
web = plugin_mgr.get("web-toolkit")
# 设置目录
web.set_static_dir("./public")
web.set_template_dir("./templates")
# 添加自定义路由
web.add_route("GET", "/api/hello", lambda req: {
"status": 200,
"headers": {"Content-Type": "application/json"},
"body": '{"message": "Hello"}'
})
# 渲染模板
html = web.render_template("page.html", {"title": "My Page", "items": [1, 2, 3]})
模板语法
<!-- 变量 -->
<h1>{{ title }}</h1>
<p>{{ description }}</p>
<!-- 条件 -->
{% if show_content %}
<div>{{ content }}</div>
{% endif %}
<!-- 循环 -->
<ul>
{% for item in items %}
<li>{{ item }}</li>
{% endfor %}
</ul>
配置
{
"config": {
"args": {
"host": "0.0.0.0",
"port": 8080,
"static_dir": "./static",
"template_dir": "./templates",
"index_files": ["index.html", "index.htm"]
}
}
}
依赖
- http-api:HTTP 服务
- http-tcp:TCP HTTP 服务