Download Tools for Designing Web Based Interfaces for Erlang/OTP

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
Tools for Designing Web Based
Interfaces for Erlang/OTP
Martin Gustafsson
Program
Why Web Based User Interfaces.
 httpd the Webserver in Erlang/OTP.
 How to use and develop with WebTool.
 Best Desing of Web Based Tools, with
Erlang/OTP.

Why Web Based User Interfaces
Easy for the user.
 Fast development,

–
–
Easy to Learn.
Fast Development.
The tool can be used from the network.
 Easy to generate printable reports.

Problems with Web based User
Interfaces
Takes little more time to start than
command-line tools.
 Interaction with the files system.
 Browser incompabilities.
 Security is problem,

–
–
Functionality that can stop the Erlang node.
Data transfer between server and client is not
secure.
httpd -The Webserver in
Erlang/OTP
Support for Basic User Authentication.
 Support for SSL.
 Support for creation of Dynamic Web Pages.
 httpd is a Apache styled Webserver.

The functionality of httpd
HTTP-request
httpd
s
HTTP-Response
mod_xxx
{response{statuscode,Body}}
Creation of dynamic Web Pages
CGI
 Eval Scheme

–

Ex: http://server:port/EvalSchemAlias/mod:func(AnyArg)
Erl Scheme
Ex: http://server:port/ErlSchemeAlias/mod/func
The Webserver will return the result of calling
mod:func(Env,Input).
Example
index(Env,Input) ->
[“\r\n\r\n”,html_head(),htmlbody(),
createMenu(Env),”</HTML>”].
createMenu(Env)->
Ag=httpd_util:key1search(
Env, http_user_agent,other),
case
mod_browser:getBrowser(Ag) of
{{msie,_},_} ->
menu(ie);
{{netscape,_},_} ->
menu(nav)
end.
menu(nav) ->
“<LAYER NAME=\”popup\”
VISIBILITY=\”hidden\”>
<TABLE>
<TR><TD>
<A HREF=./start>
Start tool
</A>
</TD></TR>
….
</TABLE>
</LAYER>”;
Starting WebTool

Create a *.tool file for each tool and save it in
the directory MyTool-vsn/priv/FileName.tool
–

Start WebTool.
–

Ex: {version,1.2},
[{config_func,{webappmon,configData,[]}}]
Ex: webtool:start().
webtool:start(Path,Port).
Point a browser to http://HostName:Port/
Callback function for WebTool
WebTool use the callback function to
receive configuration data for the tool.
 Configuration data is needed for:

–
–
–
Creating links from WebTool to the tool.
Configuration of the Webserver.
Data about how to start and stop the tool.
Developing tools to be used via
WebTool

The tools must export a callback function that
returns the configuration data needed by
WebTool.
–
Example:
configData()->
Application=my_app
RealPath=code:priv_dir(Application),
{mytool,[{web_data,{“URL”,”Linktext”}},
{alias,{erl_alias,”VPath”,[“Module”]}},
{alias,{“VirtualPath2”,RealPath}},
{start{{Mod,Func,Arg},{Mod,Func,Arg}}}]}.
Design principles for Web based
Tools

A N-layered solution has many advantages
–
–
Easier to update the code
If well designed the logic module might be
possible to use as a command-line version.
HTTP-Request
Module that
generates the
User Interface
WebPage
logic Module