LoginSignup
3
6

More than 5 years have passed since last update.

Node-REDをWebサーバー的に使う

Last updated at Posted at 2017-10-08

簡易的なWebサーバーとして使って内部にjsライブラリをもたせたり、templateノードで作成したhtmlに画像を埋め込みたりできたのでメモです。

手順

  1. スターターコードのダウンロード
  2. httpStaticで指定したフォルダへ配置
  3. cf push

1. スターターコードのダウンロード

(ダウンロード画面)
dl_starter.jpeg

(ダウンロードされたzipファイル内)
スクリーンショット 2017-10-08 14.42.53.png

2. httpStaticで指定したフォルダへ配置

bluemix-settings.jsのhttpStaticを確認すると下のようになっています。

bluemix-settings.js
   // Move the admin UI
    httpAdminRoot: '/red',
    // Serve up the welcome page
    httpStatic: path.join(__dirname,"public"),

httpStatic
ここで指定したPathを静的なWebコンテンツとして表示できます。例えば/home/username/.node-red/と指定した場合、/home/username/.node-red/index.htmlを作成すると/へアクセスすると作成したindex.htmlが表示されます。したがってhttpStaticを指定する場合はhttpAdminRootは/より下層のPathにする必要があります。

簡易Webサーバーになっているようです。
ここにファイルやフォルダを追加します。
(例)
スクリーンショット 2017-10-08 15.07.14.png

3. cf push

publicに必要なファイルを追加したらcf push
以上です。
/直下に配置できているのが確認できるかと思います。

3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6