【发布时间】:2018-02-05 12:56:00
【问题描述】:
我需要使用 http 端点在 Node-RED 仪表板上显示图像。 我做了以下事情:
- 将图像保存在 /home/pi/Pictures 中。
- 在 setting.js 文件中编辑了 httpStatic: '/home/pi/Pictures'。
- 尝试在 html 图像标签的 src 中的图像名称前使用斜杠“/”和 没有“/”但没有任何效果。
这是我的参考流程:
[
{
"id": "7b08a202.a1670c",
"type": "http in",
"z": "e5e5e9b.2a8cc18",
"name": "",
"url": "/display-image",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 112,
"y": 73,
"wires": [
[
"35ca7d97.da9dd2"
]
]
},
{
"id": "f8cf60ed.74b87",
"type": "http response",
"z": "e5e5e9b.2a8cc18",
"name": "",
"statusCode": "",
"headers": {
},
"x": 458,
"y": 70,
"wires": [
]
},
{
"id": "35ca7d97.da9dd2",
"type": "template",
"z": "e5e5e9b.2a8cc18",
"name": "SLD View",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<!DOCTYPE html>\n<html>\n <body>\n <img src=\"Barsu_SLD.png\" alt=\"Overview\" width=1000px; height=800px>\n \n </body>\n</html>",
"output": "str",
"x": 310,
"y": 136,
"wires": [
[
"f8cf60ed.74b87"
]
]
},
{
"id": "2beda89c.ca2b98",
"type": "ui_template",
"z": "e5e5e9b.2a8cc18",
"group": "d9e6ccf5.f58ab",
"name": "Display Button",
"order": 0,
"width": 0,
"height": 0,
"format": "<!DOCTYPE html>\n<html>\n <head>\n <style>\n .button {\n background-color: #086A87;\n border: none;\n color: white;\n padding: 16px 32px;\n text-align: center;\n text-decoration: none;\n font-size: 16px;\n margin: 3px 1px;\n cursor: pointer;\n border-radius: 4px;\n }\n .button_over:hover {\n background-color: #187A97;\n color: white;\n }\n </style>\n </head>\n <body>\n \n <a href=\"http://127.0.0.1:1880/BARSU-SLD/\" class=\"button button_over\" target=\"_blank\" >SLD View</a> \n \n </body>\n </html>",
"storeOutMessages": false,
"fwdInMessages": true,
"templateScope": "local",
"x": 112,
"y": 195,
"wires": [
[
]
]
},
{
"id": "d9e6ccf5.f58ab",
"type": "ui_group",
"z": "",
"name": "Test",
"tab": "1474e3ec.fb238c",
"disp": true,
"width": "6"
},
{
"id": "1474e3ec.fb238c",
"type": "ui_tab",
"z": "",
"name": "Home",
"icon": "dashboard"
}
]
任何帮助都是非常值得赞赏的。
【问题讨论】:
-
能否请您具体说明什么不起作用?
-
我无法显示在模板 (Barsu_SLD.png) 中使用的图像。你能告诉我我必须把图像放在哪里,以便我能够在仪表板上显示它吗?
-
如果您的
httpStatic路径设置正确,那么您的node-red 服务器可以使用urlhttp://localhost:1880/Barsu_SLD.png提供图像文件(假设您使用相同的主机和默认端口)。请在重新启动后向我们展示 node-red 控制台日志中的初始行...
标签: javascript html node-red