2017-01-23 9 views
1

node-redを使用してアプリケーションを作成し、node-red-dashboardでuiを作成しています。ノード赤いダッシュボード画像を含む

私はいくつかのAPI呼び出しを含み、応答に基づいて、テンプレートコントロールのImageソースを変更したいと思います。

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

だから、画像への絶対パスを使用します。しかし、イメージは読み込まれません。それを示すシンボルがあり、画像のソースはlocalhost:1880/sun.pngに設定されています。

どこに画像を配置する必要がありますか?どのパスを使用する必要がありますか?

答えて

2

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

あなたは/ホームへ/ PI/Destkop/WeatherImages次のようにすることを設定した場合: `設定した後、勤務

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

を:

... // 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を設定することができますhttp://nodered.org/docs/configuration –

+0

ダッシュボードは 'http://raspberrypi.local:1880/ui/sunを表示しようとします。 「」と指定しても'。 –

+0

これはおそらくキャッシングの問題です – hardillb

関連する問題