节点红色仪表板包括图像

时间:2017-01-23 13:51:41

标签: node.js node-red

我正在使用node-red创建一个应用程序并使用node-red-dashboard创建ui。

我已经包含了一些api调用,并根据我想要更改模板控件的Image源的响应。

<img src="/home/pi/Destkop/WeatherImages/sun.png">

所以我使用了图像的绝对路径。但是图像没有被加载。有一个符号表示图像的来源设置为localhost:1880/sun.png

我需要在哪里放置图片?我需要使用什么路径?

1 个答案:

答案 0 :(得分:3)

您无法对从Node-RED内置的Web服务器提供的文件使用本地路径,因为访问该页面的浏览器可能不在运行Node-RED的同一台计算机上。

settings.js文件中(将在〜/ .node-red中)有一个名为httpStatic的设置,您可以使用它来指定Node-RED将为静态内容提供服务的目录从

...
// When httpAdminRoot is used to move the UI to a different root path, the
// following property can be used to identify a directory of static content
// that should be served at http://localhost:1880/.
//httpStatic: '/home/nol/node-red-static/',
...

如果您将其设置为/ home / pi / Destkop / WeatherImages,如下所示:

...
// When httpAdminRoot is used to move the UI to a different root path, the
// following property can be used to identify a directory of static content
// that should be served at http://localhost:1880/.
httpStatic: '/home/pi/Desktop/WeatherImages',
...

然后您可以按如下方式设置图像src:

<img src="/sun.png">
相关问题