This VI shows how to share and refresh your front panel in the web browser.
Are you using Web Publishing Tool to share your front panel over the web? Do you want to get a little more functionality out of it? This example mimics the functionality of the Web Publishing Tool mirror setting, but gives you more flexibility in terms of the appearance. This example was made with LabVIEW 2013, which has an object-oriented approach to web services.
The following stpe is the tutorial about how to build the required web service project.
Step 1: Create Web Service
Open a Blank Project.
Right-click My Computer and select New»Web Service.
Give it a name.
Step 2: Add the VI You Want to Publish
Right-click My Computer and select Add»File.
Browse to the desired VI’s file path and click OK.
Repeat for any other VIs that you want to publish over the web.
Step 3: Add the GetImage.vi
Download this example.
Add GetImage.vi to the project as was done in Step 2.
Drag GetImage.vi into the Web Resources folder under the Web Service.
There should be (GET) appended to the end of the VI’s name. Open GetImage.vi and change the file path constant in the block diagram to match the VI you are trying to publish.
Save GetImage.vi and close it.
Step 4: Configure Web Service
Right-click the Web Service created in Step 1 and select Properties.
Click on HTTP Method VI Settings.
Click the Output Type tab.
(check or uncheck) Use Headers and Buffered.
Step 5: Add a Static Web Page
Copy the included Static folder to your project’s folder path. Make sure it contains the file index.html.
Right-click the Web Service created in Step 1 and select Add Public Content Folder…
Select the Static folder.
Note: this auto-populating subfolder will contain all web pages you want to host on this web service.
Step 6: Modify HTML Code
Open index.html (located in the Static folder) in your favorite text editor. I like notepad or notepad++.
In the Head Section, you can change the title or refresh rate to your own (currently the title is Web Service and the refresh rate is 5 seconds).
In the Body Section, note the address of the images. Change the address to match your server’s IP address. AND CHANGE THE WEB SERVICE NAME from WebServiceName to the name you gave it in step 2.
Save and close the file.
LabVIEW 2013 (or compatible)
Steps to Implement or Execute Code
Run the VI you want to display in LabVIEW.
Right-click the created Web Service and select Application Web Server»Publish.
Wait for the build to complete and click OK.
Right-click the Web Service and select Start.
Double click index.html from the LabVIEW project.
Additional Information or References VI Snippet of Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**