G Web Server Examples

Example With a Shipping VI

Here is an example of the build instructions for one of the shipping examples in the toolkit. There are also two build scripts included in the <LabVIEW>\www\examples\buildapplication that can be used to build the G Web Server into an application. If you use the build scripts you can skip to step 23.

Example for creating an application out of listdir.vi example shipped with the Internet Toolkit:

1. Select Tools » Build Application or Shared Library (DLL).
2. Set the location for the executable to be built, Destination directory to <LabVIEW>\www\examples\buildapplication\app.
3. Select Single target file containing all VIs from the Build Options list (should be selected by default).
4. Select the Source Files tab.
5. Select Add Top-level VI.
6. Select HTTP Server Control.vi from <LabVIEW>\vi.lib\addons\internet\http\http0.llb, the top level VI.
7. Select Add Dynamic VI.
8. Select HTTP Dynamic VIs.vi from <LabVIEW>\vi.lib\addons\internet\http.
9. Select Add Dynamic VI.
10. Select listdir.vi from <LabVIEW>\www\cgi-bin\examples.
(Note: any CGI VI included in a built application must keep its front panel. This can be done by choosing the VI Settings tab and scrolling to the given VI, and selecting No for the Remove Panel setting)
11. Select Add Directory Contents, from the Add Support File pull-down menu, and include <LabVIEW>\internet\http\conf\. This should include the files:
o access.cfg
o grp.txt
o lvhttp.cfg
o mime.typ
o pwd.txt
o srm.cfg
12. Select Add Support File.
13. Select index.htm and indexcgi.htm from <LabVIEW>\www\examples\buildapplication.
14. Select Add Directory Contents, from the Add Support File pull-down menu, and include <LabVIEW>\internet\www\images\.
15. Select Add Directory Contents, from the Add Support File pull-down menu, and include <LabVIEW>\internet\http\icons.
16. Select Custom Destinations.
17. Change Build destination for each of the configuration files in step 11 to <LabVIEW>\www\examples\buildapplication\app\internet\http\conf\.
18. Change Build destination for index.htm and indexcgi.htm to <LabVIEW>\www\examples\buildapplication\app\www\.
19. Change Build destination for all of the image files from step 14 to <LabVIEW>\www\examples\buildapplication\app\www\images.
20. Change Build destination for all of the icons from step 15 to <LabVIEW>\www\examples\buildapplication\app\internet\http\icons.
21. Choose the Build button.
22. Choose the Done (save .bld file first if you wish) button.
23. Navigate to the target directory and edit DocumentRoot in the <LabVIEW>\www\examples\buildapplication\app\internet\http\conf\srm.cfg file (from the built application, not the original) to be the location of the application's home directory. (The directory out of which you will serve your documents. By default, all requests are taken from this directory. Normally this is the application directory plus www, for example <LabVIEW>\www\examples\buildapplication\app\www.)
24. Make sure that the ScriptAlias line near the bottom of srm.cfg file (from the built application, not the original) is uncommented (remove the #).
25. Edit the <LabVIEW>\www\examples\buildapplication\app\internet\http\conf\lvhttp.cfg file (from the built application, not the original) so that UseDNS is set to ON.
26. Run the application.
Note: you need to set the operation control to "start" and run the G Web Server Control VI to start the G Web Server.
Note: HTTP Server Control.vi is design to be used as a subVI. It along with code to correctly set the settings from steps 23 to 25 can be used to create a VI that would be used to correctly enable the G Web Server in your application.
27. To get to the CGI VI, type in http://yourservername:portyouused/cgi-bin/VIName.vi in your browser. For example, http://localhost/cgi-bin/listdir.vi.


© National Instruments