Deploy local HTML/frontend files to PostMe (dele.fun) and get a live URL
技能名称: postme-deploy
详细描述:
| 变量 | 描述 |
|---|---|
| POSTMEAPIKEY | 必需。 你的PostMe API密钥,用于身份验证。可在 https://www.dele.fun/api-keys 获取 |
| POSTMEAPIURL |
该技能将返回一条包含实时URL的成功消息,例如:部署成功!URL:https://www.dele.fun/app/my-app-v1/。
json
{
name: postme_deploy,
description: 将本地文件夹或HTML文件部署到PostMe系统以获取实时Web URL。,
parameters: {
type: object,
properties: {
target_path: {
type: string,
description: 要部署的文件夹或HTML文件的本地路径。
},
app_name: {
type: string,
description: 应用的唯一、URL友好名称(仅限小写字母、数字和连字符)。
},
api_url: {
type: string,
description: PostMe /api/upload 端点的完整URL。默认为 https://www.dele.fun/api/upload
},
api_key: {
type: string,
description: 用于身份验证的API密钥(POSTMEAPIKEY)。
},
app_desc: {
type: string,
description: 应用功能的简短描述。
}
},
required: [
target_path,
app_name
]
}
}
python
import os
import requests
import re
from typing import Optional
def execute(
target_path: str,
app_name: str,
api_url: str = https://www.dele.fun/api/upload,
api_key: Optional[str] = None,
app_desc: Optional[str] = None
) -> str:
将本地文件夹或HTML文件部署到PostMe系统。
if not os.path.exists(target_path):
return f错误:目标路径 {target_path} 不存在。
if not re.match(r^[a-z0-9-]+$, app_name):
return 错误:app_name 只能包含小写字母、数字和连字符。
filestoupload = []
if os.path.isfile(target_path):
filestoupload.append((targetpath, os.path.basename(targetpath)))
elif os.path.isdir(target_path):
for root, , files in os.walk(targetpath):
for file in files:
file_path = os.path.join(root, file)
relpath = os.path.relpath(filepath, target_path).replace(os.sep, /)
filestoupload.append((filepath, relpath))
else:
return f错误:{target_path} 既不是文件也不是目录。
if not filestoupload:
return 错误:未找到要上传的文件。
multipartdata = [(appName, (None, appname))]
if app_desc:
multipartdata.append((appDesc, (None, appdesc)))
file_handles = []
try:
for filepath, relpath in filestoupload:
f = open(file_path, rb)
file_handles.append(f)
multipartdata.append((files, (os.path.basename(filepath), f)))
multipartdata.append((paths, (None, relpath)))
headers = {}
if api_key:
headers[Authorization] = fBearer {api_key}
headers[x-agent-user] = openclaw-agent
response = requests.post(apiurl, files=multipartdata, headers=headers)
if response.status_code in (200, 201):
data = response.json()
baseurl = apiurl.replace(/api/upload, )
return f部署成功!URL:{baseurl}{data.get(url, f/app/{appname}/)}
else:
try:
err_msg = response.json().get(error, response.text)
except:
err_msg = response.text
return f部署失败(状态码 {response.statuscode}):{errmsg}
except Exception as e:
return f部署期间出错:{str(e)}
finally:
for f in file_handles:
f.close()
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 postme-deploy-1775945304 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 postme-deploy-1775945304 技能
skillhub install postme-deploy-1775945304
文件大小: 2.64 KB | 发布时间: 2026-4-12 11:03