EN

The POWER-KI programming language for IA

Develop solutions from Factory Automation to Web Application

©®2014 XPLAB - Research in Automation
© 2014 APX - Advanced Programming Exploitation
Brescia - Italy

Simple Web Server

Begin to understand PWK web server capabilities

Using a simple WUI explore HTML5, and CSS3 design. From the assembly start the web server that provides static and dynamic content.

2014-08-13 20:03:22


In this article we present the realization of a simple web server that allows the publication of a WUI (Web User Interface).
First, we will create a package containing the assemby (executable code), a GUI (monitor), a WUI (myWeb) and three resources: two images (Bnr, smile) and a background for the GUI (sfd).
The Package

GUI (Graphic User Interface)

The purpose of the GUI is to provide a feed back about the running state of the program and a way to terminate it. The GUI content only a tittle and a label.
The GUI and the form in LIVE mode

The WUI (Web User Interface)

The WUI contains the index.html page and the smile _FRGM_ that is instanced 3 times inside the _REF_ element of the page.
The WUI and the page and the preview ofn the page.
The Monitor in the CLOSE item of the trig set to 1 the global variable stop@\Main (see next).
Assembly : The GUI Monitor
The main EXO does a simple work: preset to 0 the stop symbol, fill the TEXT of the GUI label with a message, set the title of the GIU and sent it the command to Show, call the SetUp method of the Web VAR, then wait inside a loop till the stop symbol goes to 1.
Assembly: Main EXO
The web VAR contains some global symbol and three methods: SetUp, TrigGet and Close (unused in this demo),
Assembly the VAR Web
With the WUI_OPN the MyWeb WUI is opened and the pointer (PTR) is saved in a global symbol of the VAR. The next operation are related to web. With WEB_NEW the service is created, to it a TRIG is associated to serve HTTP GET requests, and then is STARTED.
Assembly: SetUp the web
At any HTML GET request a TrigGet Method of the VAR WEB is started as a new thread. The set parameter are filled with the data of the call.
Assembly: the TRIG for HTML GET request
If the reqUrl parameter is emply , is filled with "index.html". In LBL Normalization , slash are normalized and the first of it, if exist, is removed.
Trig : first operation
In the IF item the core of the WUI generation, in fact if the rqsUrs is an .html page, with the function WUI_HTML the genaration proces is activated. If the function return a valid htm symbol, that is, containing the HTML code, the TRIG return it to the requester browser.
Trig: HTML generation



The code inside the last LBL serve static contents from the web dir, (not user here, you should define the symb in VAR). In fact in this demo, static image are keept from the package and the proper link is generated by the WUI_HTML function.
Trig: static content

Link

Download DemoWeb01.pwk

legal
privacy
ethics

©2010-2016 XPLAB - Research in Automation - Brescia - ITALY - [IT03259580177] This Website is a XAILS project Written and Directed by POWER-KI - All right reserved,