Hi,
I suppose it is a rather stupid question, but I don't understand what to do when making a webpage/site.
I read '[http://{your-server-ip:1880/simple]' - what does that mean? Do I have to make a simple directory and if so, in what directory of my Raspberry Pi (that is where Node-RED is installed).
I want to open the page/site from another pc with a browser.
Thank you for helping me further.
Yvonne
Take a look at
https://cookbook.nodered.org/http/create-an-http-endpoint
where Node-RED builds a webpage, no html on disk.
If you want to serve a file from disk it gets a little more complicated
https://cookbook.nodered.org/http/serve-a-local-file
But you will also need to specify in the Node-RED settings file where the root of your web data is stored see How to enable ability to input local image files in to node red dashboard
Are you going to use the node red dashboard to make webpages?
Dear Colin and ukmoose,
Thank you so much for your fast reply. I will study what you gave me as information. If I have problems, I hope I may come back to you.
Yvonne
In my settings.js file I want to uncomment:
httpStatic: '/home/node-red-static/' but I have the path '/home/nol/node-red-static/'
Is that the same?
Thanks
You have several options:
-
http-in/-out nodes as a pair - enables you to listen for incoming web requests and provide a response
-
Dashboard - Creates a single-page web app using Angular v1. Connects data dynamically using websockets
-
Configure the static resource folder in Node-RED's settings.js file - allows you to use Node-RED as a more traditional web server using static files.
-
Use a contrib node such as uibuilder - uibuilder allows you to create multiple pages with dynamic data connection using websockets. It also facilitates the use of additional front-end libraries such as REACT, VueJS, etc.
All of these allow you to easily create web pages. In each case, the http://{your-server-ip:1880
remains the same since all of the options use the ExpressJS server that Node-RED itself creates and uses. ExpressJS is the most popular web application library for Node.js.
1 Like
You should put there the path to where you wish to serve the data from. If you are putting the files in /home/nol/node-red-static
then that is what you should specify.
Thank you. Time to study!!
That is Nick's little trap left for us all as a lesson in making sure we change default settings
One suspects that, when the settings.js file was first introduced to the world, nol
was the user name he was using at the time. On a standard Pi installation, you would want something like /home/pi/.node-red/public
or whatever you wanted to call it. It could, of course actually be anywhere as long as the user id running Node-RED has at least read-only access to the folder.
Thank you all for your response.
I understand it a bit better, but now I have additional questions.
I succeeded in making a static webpage, but is it possible to inclose the page in an existing application (see printscreen)?
I now open the webpage with the ipaddress:1880/hello (for instance), but it is opened in a new window.
Is it advisable to install Express?
Thank you so much.
Yvonne
You could do it using a html iframe but it might be easier to investigate if the dashboard template node would allow you to do what you want.
Thank you ukmoose.
Do I have to use then the websocket instead of the http node pair in order to create a dynamic page?
If you mean using an iframe - no , try googling iframe...
If you meant if you were using the dashboard template node, no, if you click on the dashboard template node and look at the info panel you should find enough information on how to use it