HTML node? #38

Closed
ImTheDeveloper opened this Issue Oct 12, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@ImTheDeveloper

This is more for discussion than anything . I think a node that would allow you to deploy a HTML page would finish the loop from hardware/software. Maybe allowing the node to just have you paste your HTML directly into a text area and as with the http posts select a subdirectory/file name e.g server/topic/name.HTML format. However I know this then would spark the argument for other languages etc but at the very least it would allow you to link a http post node to a HTML form and easily pass the form output which could then be stored in the mongodb etc.

Anyway just an idea for now. It could allow me to totally ditch my lighttpd server.

@knolleary

This comment has been minimized.

Show comment
Hide comment
@knolleary

knolleary Oct 12, 2013

Member

Hi,

We already have an http node for just this sort of thing.

Assuming you're running a recent extract from git, rather than npm install, then import (Ctrl-I) the following:

[{"id":"d2ea6d6b.2d159","type":"http in","name":"","url":"/hello","method":"get","x":160,"y":400,"wires":[["4ea73e4a.b158c"]]},{"id":"4ea73e4a.b158c","type":"template","name":"","template":"Hello World!","x":301,"y":401,"wires":[["d6c85f9.f2937a"]]},{"id":"d6c85f9.f2937a","type":"http response","name":"","x":443,"y":402,"wires":[]}]

Then, browse to http://localhost:1880/hello (ie whatever base url you access the UI from, with /hello appended).

The http in node allows you to define an http endpoint, relative to the node-red UI url.

The http response node can then be used to send whatever content you want back.

In the example above, a template node between the two simple inserts some static content - which could be a complete HTML file. Okay for simple things, but I wouldn't want to use it to serve an entire site - all the content would be embedded in your flows file.

Alternatively, if you're comfortable with Node.js, you can embed node-red and run whatever express apps you want along side it for serving content. The docs at that link shows how to embed node-red within an express app that also serves static files from a local directory.

Finally, worth noting we do now have a Google Group for this sort of question/discussion - https://groups.google.com/forum/#!forum/node-red

Member

knolleary commented Oct 12, 2013

Hi,

We already have an http node for just this sort of thing.

Assuming you're running a recent extract from git, rather than npm install, then import (Ctrl-I) the following:

[{"id":"d2ea6d6b.2d159","type":"http in","name":"","url":"/hello","method":"get","x":160,"y":400,"wires":[["4ea73e4a.b158c"]]},{"id":"4ea73e4a.b158c","type":"template","name":"","template":"Hello World!","x":301,"y":401,"wires":[["d6c85f9.f2937a"]]},{"id":"d6c85f9.f2937a","type":"http response","name":"","x":443,"y":402,"wires":[]}]

Then, browse to http://localhost:1880/hello (ie whatever base url you access the UI from, with /hello appended).

The http in node allows you to define an http endpoint, relative to the node-red UI url.

The http response node can then be used to send whatever content you want back.

In the example above, a template node between the two simple inserts some static content - which could be a complete HTML file. Okay for simple things, but I wouldn't want to use it to serve an entire site - all the content would be embedded in your flows file.

Alternatively, if you're comfortable with Node.js, you can embed node-red and run whatever express apps you want along side it for serving content. The docs at that link shows how to embed node-red within an express app that also serves static files from a local directory.

Finally, worth noting we do now have a Google Group for this sort of question/discussion - https://groups.google.com/forum/#!forum/node-red

@knolleary knolleary closed this Oct 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment