Serving HTML / JS / CSS with HTTP Node

1,090 views
Skip to first unread message

Jean-Philippe Encausse

unread,
Oct 25, 2016, 4:24:48 PM10/25/16
to Node-RED
Hi,

I'd like to serve an HTML with some JS and CSS.

To do that I create:

  • HTTP IN on /myFile   =>   Template => HTTP OUT
  • HTTP IN on /myJS   =>   Template => HTTP OUT
  • HTTP IN on /myCSS   =>   Template => HTTP OUT
It works ! And I can also edit each files but I have few questions:


1. There is no CSS editor in template node (only HTML and JS). Is there a workaround ?

2. When serving CSS I have to add a header why not adding it to HTTP OUT node ?
msg.headers['content-type'] = "text/css";

3. If I want to declare some local static files I have to put them in common static folder. Is there a good practice to let a node-contrib to declare it's own static folder ?

Thanks

Nicholas O'Leary

unread,
Oct 25, 2016, 4:59:42 PM10/25/16
to Node-RED Mailing List
Hi,

1. the Template node has 'CSS' in the list of Syntax Highlighting options... is there something else you had in mind?

2. that has been mooted before - allow you to set some of the response options in the node itself... just not been captured anywhere to do anything about it. Have added an item to the backlog to cover it: https://trello.com/c/QQojUFlW/62-http-response-set-response-properties-in-the-node-itself

3. See, for example, the geofence node that serves up additional resources for its edit template - https://github.com/hardillb/node-red-node-geofence/blob/master/geofence.js#L116

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+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/bdde11b9-6399-4340-bd20-c6d89dcb6eca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jean-Philippe Encausse

unread,
Oct 25, 2016, 5:05:03 PM10/25/16
to node...@googlegroups.com
1. the Template node has 'CSS' in the list of Syntax Highlighting options... is there something else you had in mind?

Hum ? Is it new ? I only have :
- mustache
- HTML
- JSON
- JavaScript
- Markdown
- none

 
2. that has been mooted before - allow you to set some of the response options in the node itself... just not been captured anywhere to do anything about it. Have added an item to the backlog to cover it: https://trello.com/c/QQojUFlW/62-http-response-set-response-properties-in-the-node-itself


That would be great
In my case, the request accept text/css but it's not forwarded to the response content-type

 
3. See, for example, the geofence node that serves up additional resources for its edit template - https://github.com/hardillb/node-red-node-geofence/blob/master/geofence.js#L116


Hum ok thanks got it !



--
Jean-Philippe Encausse - R&D / IoT / Innovations
http://www.encausse.net - http://arm-avocats.fr
Twitter: @JpEncausse - Mob: +33 6 82 12 56 99 
Do it Once, Use it Twice ~ Do it Twice, Make It Once

Dave C-J

unread,
Oct 25, 2016, 5:07:31 PM10/25/16
to node...@googlegroups.com
Is there - in 15.1 (or should be)
Inline images 1

Jean-Philippe Encausse

unread,
Oct 25, 2016, 5:17:10 PM10/25/16
to node...@googlegroups.com
Ah ok I'm not up to date 0.14 thanks I try to update !

On Tue, Oct 25, 2016 at 11:07 PM, Dave C-J <dce...@gmail.com> wrote:
Is there - in 15.1 (or should be)
Inline images 1

--
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/8gRbUYlEfyc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@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.

Nathanaël Lécaudé

unread,
Oct 25, 2016, 7:55:50 PM10/25/16
to Node-RED

Julian Knight

unread,
Oct 27, 2016, 7:39:41 AM10/27/16
to Node-RED
I've done something similar in the examples I created for having live return messaging from a web page (this was before UI/Dashboard was available) and for the example of a debug web page. In fact, I think they do both things, both serve static resource files and allow passing (at least of scripts) from upstream nodes.
Reply all
Reply to author
Forward
0 new messages