2017-01-23 2 views
1

node-red을 사용하여 응용 프로그램을 만들고 node-red-dashboard을 사용하여 응용 프로그램을 만듭니다.노드 빨간색 대시 보드 이미지 포함

API 호출이 포함되어 있으며 응답을 기반으로 템플릿 컨트롤의 이미지 소스를 변경하려고합니다.

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

그래서 이미지 절대 경로를 사용 하였다. 그러나 이미지가로드되지 않습니다. 이미지의 소스가 localhost:1880/sun.png으로 설정되었음을 나타내는 기호가 있습니다.

어디에서 이미지를 배치해야합니까? 어떤 경로를 사용해야합니까?

답변

2

노드 -RED에 내장 된 웹 서버에서 제공되는 파일에 로컬 경로를 사용할 수 없습니다. 페이지에 액세스하는 브라우저가 Node-RED가 실행되는 컴퓨터와 다를 수 있기 때문입니다.

settings.js 파일 (~/.node-red)에는 ​​httpStatic이라는 설정이 있습니다.이 설정을 사용하면 노드 -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/', 
... 

당신은/홈/PI/Destkop이/WeatherImages에 다음과 같은 것을 설정 한 경우 :

<img src="/sun.png"> 
+0

이 설정 한 후 근무': 다음과 같이 다음 이미지 SRC를 설정할 수 있습니다

... // 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', ... 

http://nodered.org/docs/configuration –

+0

대시 보드는 'http : //raspberrypi.local : 1880/ui/sun'을 표시하려고 시도합니다. .png'내가'을 지정할 때조차도'. –

+0

캐시 문제 일 가능성이 가장 높습니다. – hardillb