node-red和python的结合使用,直接就是神器,前端和后端就都有了
图片如下
见代码
[
{
"id": "59d5b15.ad8035",
"type": "template",
"z": "eeb650e6.286b2",
"name": "python content",
"field": "payload",
"fieldType": "msg",
"format": "python",
"syntax": "mustache",
"template": "import os\na=os.getcwd()\nprint(a)",
"output": "str",
"x": 380,
"y": 140,
"wires": [
[
"674727ec.c18738"
]
]
},
{
"id": "afcb6ff0.29a97",
"type": "inject",
"z": "eeb650e6.286b2",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 140,
"wires": [
[
"59d5b15.ad8035"
]
]
},
{
"id": "5bdf8e81.b3b82",
"type": "exec",
"z": "eeb650e6.286b2",
"command": "python C:\\data\\1\\py001.py",
"addpay": "payload",
"append": "",
"useSpawn": "false",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "",
"x": 430,
"y": 300,
"wires": [
[
"ef46f3bb.2b14f"
],
[],
[]
]
},
{
"id": "674727ec.c18738",
"type": "file",
"z": "eeb650e6.286b2",
"name": "",
"filename": "C:\\data\\1\\py001.py",
"appendNewline": true,
"createDir": true,
"overwriteFile": "true",
"encoding": "none",
"x": 590,
"y": 140,
"wires": [
[
"73781b8.e38c0e4"
]
]
},
{
"id": "73781b8.e38c0e4",
"type": "delay",
"z": "eeb650e6.286b2",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 380,
"y": 240,
"wires": [
[
"5bdf8e81.b3b82"
]
]
},
{
"id": "ef46f3bb.2b14f",
"type": "debug",
"z": "eeb650e6.286b2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 630,
"y": 300,
"wires": []
},
{
"id": "8eb98748.6f58d8",
"type": "comment",
"z": "eeb650e6.286b2",
"name": "输入python代码进行执行",
"info": "1.写入python文件\n2.构建文件的程序",
"x": 230,
"y": 100,
"wires": []
}
]