mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
fix(deploy): 移除对main分支的拉取尝试 feat(task): 添加节点处理器模块和示例代码 refactor(scheduler): 改进任务执行包装器支持完整Python语法 style(monitor): 允许资源文件URL为相对路径 chore(deps): 降级requests版本到2.32.3 refactor(frontend): 更新节点任务示例代码 refactor(docker): 优化docker-compose配置和健康检查 refactor(resource): 加强文件路径安全检查和URL处理
43 lines
968 B
Python
43 lines
968 B
Python
"""
|
|
示例处理器模块
|
|
|
|
提供简单的示例方法供节点执行函数调用
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
def demo_handler(*args, **kwargs) -> dict:
|
|
"""示例处理器"""
|
|
return {
|
|
"message": "Hello from demo_handler!",
|
|
"args": args,
|
|
"kwargs": kwargs,
|
|
"time": datetime.now().isoformat(),
|
|
}
|
|
|
|
|
|
def process_data(data: list, operation: str = "sum") -> dict:
|
|
"""
|
|
简单数据处理
|
|
|
|
operation: sum, avg, max, min, count
|
|
"""
|
|
if not data:
|
|
return {"error": "数据为空"}
|
|
|
|
if operation == "sum":
|
|
result = sum(data)
|
|
elif operation == "avg":
|
|
result = sum(data) / len(data)
|
|
elif operation == "max":
|
|
result = max(data)
|
|
elif operation == "min":
|
|
result = min(data)
|
|
elif operation == "count":
|
|
result = len(data)
|
|
else:
|
|
return {"error": f"不支持的操作: {operation}"}
|
|
|
|
return {"operation": operation, "result": result}
|