6
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node-REDについて

Last updated at Posted at 2017-11-13

Node-REDを触ったのでメモ

Node-REDとは

Node-REDとは、APIやら"デバイス"やらをブラウザのマウス操作で直感的にネットワークを構築できるプラットホーム。

Node RED   vforcedevbot.au syd.mybluemix.net.png

OSSで、Node.jsが動く環境なら何処でも動かせる。

APIの作成

hoge.json
[
  {
    "id": "49a4313b.c6b4e",
    "type": "tab",
    "label": "フロー 1"
  },
  {
    "id": "5df2e6f2.7476c8",
    "type": "http in",
    "z": "49a4313b.c6b4e",
    "name": "",
    "url": "/signhack",
    "method": "get",
    "upload": false,
    "swaggerDoc": "",
    "x": 100,
    "y": 100,
    "wires": [
      [
        "9b6b3919.b1e9c8"
      ]
    ]
  },
  {
    "id": "1266dc4.c083924",
    "type": "http response",
    "z": "49a4313b.c6b4e",
    "name": "",
    "statusCode": "",
    "headers": {},
    "x": 450,
    "y": 100,
    "wires": []
  },
  {
    "id": "9b6b3919.b1e9c8",
    "type": "function",
    "z": "49a4313b.c6b4e",
    "name": "Response Body",
    "func": "msg.payload=\"Hello! World!!\"\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 280,
    "y": 100,
    "wires": [
      [
        "1266dc4.c083924"
      ]
    ]
  }
]

上記jsonコードをCopyし、「読み込み」 -> 「クリップボード」すると以下フローが追加される。

node-red02.png

各ノードは、

  1. 入力として「GET /signhack」のアクセスを受け付ける
  2. Responseの中身を定義できる(「Hello! World!!」を設定した)
  3. HTTPのレスポンスヘッダを定義する

この状態でデプロイし、「 http://localhost:1880/signhack 」にアクセスすると
「Hello! World!!」を表示できることが確認できる。

すぐ更新予定。

6
11
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
6
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?