Jump to content

dynamic content in other web servers


Recommended Posts

Nothing really to say except nice work. :worshippy:

I have come to the conclusion that too little rediscovery is sought and many would learn a great deal by doing exercises from first principles like this of technology we all take for granted.

Edited by ShaunR
  • Like 1
Link to comment

Thanks :)

 

In the other thread I mentioned I used this to make a quick demo for freeboard using the CVT. I've attached the demo here.

To use it:

1. Unzip the attached freeboard demo.zip

2. Install the CVT (current value table) from VI Package manager

3. Download https://caddyserver.com/download and extract to the same folder as the zip. Caddy.exe and "caddyfile" should be in the same directory.

4. Optional: switch up the ports in "caddyfile".

5. Open zip/lv/sampleweb.lvproj, then open server.vi

6. Optional: switch up the ports

7. Press run

8. Run caddy.exe

9. Go to localhost in your browser.

10. At the top, press "Load Freeboard", then select zip/lv/http and ws.json

11. Change values on the front panel of server.vi.

 

There are 2 sets of data sources, one set uses websockets and the other uses http requests. Both provide the same data which looks like this:

{
"humidity": 2.377959,
"temp": 0.000000,
"label": "jkjk",
"set": [1],
"onoff": true
}
 
Note: the code is not great, just something I threw together really fast with pieces of the CVT web library on ni.com/referencedesigns. However one nice thing is you can see that creating a web service like this requires 2 functions, "get" and an initialization helper. The other nice thing is that the web service didn't start until after my application did, so I know exactly what the state of my system is when the ws starts (vs deploying from the project and then initializing later which is what CVT web has to do).

freeboard demo.zip

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.