What is the best way to host client side HTML/CSS/JS

299 views
Skip to first unread message

Cory Guynn

unread,
Aug 1, 2016, 8:02:36 AM8/1/16
to Node-RED
I've built a backend system with Node-RED, but now need to deliver your typical /public static client files. I know you can use templates etc, to deliver an HTML page but it starts getting a little messy as you include script and CSS files. I also realize you can chain the templates by including {{{msg.payload.style}} but is this the best way?

If anybody has an example of a typical front-end deployment using Node-RED it would be really appreciated.

Thanks!


Nicholas O'Leary

unread,
Aug 1, 2016, 8:12:09 AM8/1/16
to Node-RED Mailing List
If you set the 'httpStatic' property in your settings file you can easily serve up static content alongside (but outside of) your flows.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Cory Guynn

unread,
Aug 1, 2016, 9:42:57 AM8/1/16
to Node-RED
Thanks Nick, as always.

It is too bad there isn't a way to do this from within the Flow editor. But for now, I have a working solution. 

Does it make sense to try to create a node/config that allows one to manage their static filesystem? 

Cheers,
Cory

Dave C-J

unread,
Aug 1, 2016, 10:13:08 AM8/1/16
to node...@googlegroups.com
well then you will need /want to manage the files within, etc... 

Cory Guynn

unread,
Aug 1, 2016, 10:27:05 AM8/1/16
to Node-RED
For the record (and future notes), this is how I build a simple front end with a Flow.

The key to this was using the Set.property and specify the purpose (i.e script/css)
I then place the following in my final HTML template
<style>{{{msg.style}}}</style>
<script>{{{msg.script}}}</script>







Hope this helps somebody else in the future.

-Cory

Dave C-J

unread,
Aug 1, 2016, 10:39:42 AM8/1/16
to node...@googlegroups.com
feel free to also add as an example to flows.nodered.org 
Thanks

Nathanaël Lécaudé

unread,
Aug 1, 2016, 5:12:39 PM8/1/16
to Node-RED
Very elegant and clever ! Thanks for sharing !

Cory Guynn

unread,
Aug 2, 2016, 6:17:34 AM8/2/16
to Node-RED
Because I appreciate good documentation, I've created a proper example with screenshots.


I wish we could track how many people use this flow and others (to satisfy my ego ;)

Cheers,
Cory

Paul Reed

unread,
Aug 2, 2016, 7:37:26 AM8/2/16
to Node-RED
Very nice Cory, appreciate you taking the time to do a helpful guide.

Nathanaël Lécaudé

unread,
Aug 2, 2016, 2:40:25 PM8/2/16
to Node-RED
I sent a PR to node-red to hilight CSS in the template node which was accepted, will be even better soon :)

Cory Guynn

unread,
Aug 2, 2016, 3:15:30 PM8/2/16
to node...@googlegroups.com

Cool, the lack of CSS highlighting was bothering me too :)


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/q4DKaX87Ano/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Ty George

unread,
Aug 2, 2016, 4:53:10 PM8/2/16
to Node-RED
Sweet was looking for something just like this a couple days ago... You rock sir :)

Thanks for the good documentation too :) 

Ty

JR01

unread,
Aug 3, 2016, 6:07:37 AM8/3/16
to Node-RED
Wow Cory, have not tried it yet, using dashboard now, but shure something will come up where I will try your approach here, brilliant! It bugged me that without a oriper editor I have to put html, script and style in a template, this cleans it up nicely, and probably drives re use!

Cory Guynn

unread,
Aug 3, 2016, 6:32:25 AM8/3/16
to Node-RED
Great feedback! Glad this is helping the Node-RED community! 
I'm going to present this platform and my solutions to many of the Cisco engineers to get more involved!

On Wed, Aug 3, 2016 at 11:07 AM JR01 <je...@familyroux.com> wrote:
Wow Cory, have not tried it yet, using dashboard now, but shure something will come up where I will try your approach here, brilliant! It bugged me that without a oriper editor I have to put html, script and style in a template, this cleans it up nicely, and probably drives re use!

--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/q4DKaX87Ano/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages