Node-RED で form を使う

Node-RED で form を使うサンプルです。

![form_jul2501.png](https://qiita-image-store.s3.amazonaws.com/0/179446/d3ab3653-172b-0b5f-8391-88fc81933bc1.png)

実行時の様子

![form_jul2502.png](https://qiita-image-store.s3.amazonaws.com/0/179446/14815fbc-7ddb-a099-e271-ebf8bf0ebddf.png)

![form_jul2503.png](https://qiita-image-store.s3.amazonaws.com/0/179446/b6a4f010-7468-95a3-04aa-aba1271cbbc1.png)

プログラム

```json:form.json
[
  {
    "id": "ba7d8bc8.b18f58",
    "type": "http in",
    "z": "46e10f37.bf2a5",
    "name": "",
    "url": "/form",
    "method": "get",
    "upload": false,
    "swaggerDoc": "",
    "x": 109,
    "y": 200,
    "wires": [
      [
        "a3ed8e66.50625"
      ]
    ]
  },
  {
    "id": "bcad5253.471ae8",
    "type": "http response",
    "z": "46e10f37.bf2a5",
    "name": "",
    "statusCode": "",
    "headers": {},
    "x": 533,
    "y": 200,
    "wires": []
  },
  {
    "id": "a3ed8e66.50625",
    "type": "template",
    "z": "46e10f37.bf2a5",
    "name": "form",
    "field": "payload",
    "fieldType": "msg",
    "format": "handlebars",
    "syntax": "mustache",
    "template": "<html lang='ja'>\n    <head>\n        <title>POST のテスト</title>\n    </head>\n    <body>\n        <h2>POST のテスト</h2>\n<form action=\"http://127.0.0.1:1880/bb\" method=\"POST\">\n    お問い合わせタイトル:<p />\n    <input type=\"text\" name=\"title\" size=\"50\">\n    <p />\n    <input type=\"submit\" value=\"お問い合わせ内容の確認\">\n    </form>\n    Jul/25/2017 AM 11:53<p />\n    </body>\n    </html>\n    \n    \n</form>",
    "output": "str",
    "x": 277,
    "y": 200,
    "wires": [
      [
        "bcad5253.471ae8"
      ]
    ]
  }
]
```

```json:bb.json
[
  {
    "id": "f17b8745.3cc6d",
    "type": "http in",
    "z": "46e10f37.bf2a5",
    "name": "",
    "url": "/bb",
    "method": "post",
    "upload": false,
    "swaggerDoc": "",
    "x": 118,
    "y": 316,
    "wires": [
      [
        "8fef4df5.1fae6",
        "5a43b9ae.0b486"
      ]
    ]
  },
  {
    "id": "9834b276.928e9",
    "type": "http response",
    "z": "46e10f37.bf2a5",
    "name": "",
    "statusCode": "",
    "headers": {},
    "x": 535,
    "y": 300,
    "wires": []
  },
  {
    "id": "29cd8166.a6720e",
    "type": "debug",
    "z": "46e10f37.bf2a5",
    "name": "",
    "active": true,
    "console": "false",
    "complete": "false",
    "x": 520,
    "y": 380,
    "wires": []
  },
  {
    "id": "8fef4df5.1fae6",
    "type": "function",
    "z": "46e10f37.bf2a5",
    "name": "msg.payload",
    "func": "msg.payload=JSON.stringify(msg.payload)\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 300,
    "y": 380,
    "wires": [
      [
        "29cd8166.a6720e"
      ]
    ]
  },
  {
    "id": "5a43b9ae.0b486",
    "type": "template",
    "z": "46e10f37.bf2a5",
    "name": "post",
    "field": "payload",
    "fieldType": "msg",
    "format": "handlebars",
    "syntax": "mustache",
    "template": "<html lang='ja'>\n    <head>\n        <title>POST</title>\n    </head>\n    <body>\nThis is the payload.title: {{payload.title}} !<p />\nJul/25/2017 PM 12:32<p />\n</body>\n</html>",
    "output": "str",
    "x": 313,
    "y": 300,
    "wires": [
      [
        "9834b276.928e9"
      ]
    ]
  }
]
```