Skip to main content

Python capability decorator for creating modular applications

Project description

PyCapabilityDecorator 说明文档

能力插件,将普通代码转换为能力插件

支持: 1. 定义 capability 元数据,包括初始化参数描述 (init_params) 和语言类型 (language_type)。 2. 注册顶级 CLI 命令(@option),支持可选的 alias,name 默认为函数名。 3. 添加顶级 --capability 选项输出所有 capability 元数据。 4. 添加顶级 init 命令执行初始化。 5. init_params 元数据描述初始化参数。 6. server(命令) 运行服务器 服务自动注册 pages 和 methods 页面模板路径 assets/pages 静态资源路径 assets/static

    访问页面:
        http://127.0.0.1:5000/capability/<>/pages/<>
    运行方法:
        http://127.0.0.1:5000/capability/<>/methods/<>

生命周期: 1.register(命令) 注册 capability 元数据 2.init(命令) 初始化 3.start(命令) 启动能力 4.stop(命令) 停止能力 5.destroy(命令) 销毁能力

使用

安装

pip install pycapabilitydecorator

示例

最简单的用法

# simple.py
from pycapabilitydecorator  import capability

# ---- 最简单能力接入
@capability.option()
def function1():
    return {
        "code": 0,
        "message": "[function1]成功"
    }

启动

python simple.py  server

执行方法 参数m 或者 method

curl http://127.0.0.1:5000/methods/simple/function1

访问页面

curl http://127.0.0.1:5000/pages/simple/home.html

项目编译

# 构建
uv build



# 测试安装1
pip install dist/pycapabilitydecorator-0.0.1-py3-none-any.whl


# 测试安装2
pip install -e


# 运行示例文件

cd examples/simple

python capability_simple.py server


# 安装 twine
pip install twine

# 上传到 PyPI

python -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycapabilitydecorator-0.0.2.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycapabilitydecorator-0.0.2-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file pycapabilitydecorator-0.0.2.tar.gz.

File metadata

  • Download URL: pycapabilitydecorator-0.0.2.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for pycapabilitydecorator-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d00ed5e226408bcab4f81d70e7fa117c5240acd68bc80037917eebd25a267a5e
MD5 c1ac1124a305a049b19b6fb79ddfab37
BLAKE2b-256 70de7dca99c0156867228647e75e32a77c4a8d8b660091994a3850aaf8b66bb9

See more details on using hashes here.

File details

Details for the file pycapabilitydecorator-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pycapabilitydecorator-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db3242c848129676ee295dc880a8a8cce1100a17c7f0331ab2972ae3faf223d4
MD5 b36d8eba26d6d95ebabd24cb363df791
BLAKE2b-256 60543282dfd417242d8fad9f529e145a16d901d97a5e70ef9813b9af41a71777

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page