IBM Bluemix Watson Node Red网页参考

时间:2016-10-15 22:30:28

标签: html ibm-cloud node-red

我已经广泛搜索了一个看似相当简单的问题,但没有找到答案。有人知道如何引用在IBM Bluemix上运行的Node Red中创建的网页吗?这是我的流程......

Basic node red flow

我的节点中的http正在引用" / temp1"但当我用" / temp1"键入我的bluemix地址时最后我得到错误"不能GET / temp1"。这似乎很有用,我确信它只是参考中的设置或缺少字符。非常感谢你的帮助。这是我的网页html顺便说一句......

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
    <head>
    <title>Test Home HVAC Zone Control</title>
    </head>
    <body>
        <h2>
            WebSocket Test
        </h2>
        Outside Temperature: <input id="display_external_temperature" type="text" value="0"></input><br>
        Media Room:<br>
        Set Temperature: <input id="mr_set_temp" type="text" value="0"></input><br>
        Current Temperature: <div id="mr_temp">0</div><br>
        Humidity: <div id="mr_humidity">0</div><br>
        DC Voltage: <div id="mr_vcc">0</div><br>
        Status: <div id="status">unknown</div>


    </body>
</html>

1 个答案:

答案 0 :(得分:0)

您需要设置一个合适的标题,例如在html之后添加一个函数节点:

msg.headers={"Content-Type":"text/html"}
return msg;

以下是修改过的流程:

[{"id":"d6ed730e.41fab8","type":"http in","z":"f0084239.95c63","name":"/temp","url":"/temp","method":"get","swaggerDoc":"","x":88.5,"y":425.40000915527344,"wires":[["6b3a011d.14e8d"]]},{"id":"6b3a011d.14e8d","type":"template","z":"f0084239.95c63","name":"html","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n<html>\n    <head>\n    <title>Test Home HVAC Zone Control</title>\n    </head>\n    <body>\n        <h2>\n            WebSocket Test\n        </h2>\n        Outside Temperature: <input id=\"display_external_temperature\" type=\"text\" value=\"0\"></input><br>\n        Media Room:<br>\n        Set Temperature: <input id=\"mr_set_temp\" type=\"text\" value=\"0\"></input><br>\n        Current Temperature: <div id=\"mr_temp\">0</div><br>\n        Humidity: <div id=\"mr_humidity\">0</div><br>\n        DC Voltage: <div id=\"mr_vcc\">0</div><br>\n        Status: <div id=\"status\">unknown</div>\n\n\n    </body>\n</html>","x":283.49998474121094,"y":416.40000915527344,"wires":[["9ac696a6.89a578"]]},{"id":"9ac696a6.89a578","type":"function","z":"f0084239.95c63","name":"setHTTPheader","func":"msg.headers={\"Content-Type\":\"text/html\"}\nreturn msg;","outputs":1,"noerr":0,"x":514.2000122070312,"y":419.20001220703125,"wires":[["dc5c1338.e50888"]]},{"id":"dc5c1338.e50888","type":"http response","z":"f0084239.95c63","name":"/temp","x":745.4999847412109,"y":405.8000030517578,"wires":[]}]