EmbedIT-WebIT

 view release on metacpan or  search on metacpan

webdemo/test_site/pod.html  view on Meta::CPAN

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>WebIT</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">


<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">Synopsis</a></li>
	<li><a href="#description">Description</a></li>
	<li><a href="#things_to_avoid">Things to avoid</a></li>
	<li><a href="#configuration">Configuration</a></li>
	<li><a href="#methods">Methods</a></li>
	<li><a href="#webit_and_soap__wsdl">WebIT and SOAP::WSDL</a></li>
	<li><a href="#requirements">Requirements</a></li>
	<li><a href="#copyright">Copyright</a></li>
</ul>

<hr name="index" />
</div>
<!-- INDEX END -->

<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Embeded::WebIT - A small yet very effective embeded web server for any perl application</p>
<p>
</p>
<hr />
<h1><a name="synopsis">Synopsis</a></h1>
<pre>
  use Embeded::WebIT;</pre>
<pre>
  $server = new Embeded::WebIT( SERVER_NAME     =&gt; 'www.my.org',
                                SERVER_IP       =&gt; '127.0.0.1',
                                SERVER_PORT     =&gt; 8080,
                                SOFTWARE        =&gt; 'MyApp web server',
                                QUEUE_SIZE      =&gt; 100,
                                RUN_AS_USER     =&gt; nobody,
                                RUN_AS_GROUP    =&gt; nogroup,
                                WAIT_RESPONSE   =&gt; 1,
                                IMMED_CLOSE     =&gt; 1,
                                EMBED_PERL      =&gt; 1,
                                FORK_CONN       =&gt; 0,
                                SETUP_ENV       =&gt; 1,
                                SERVER_ADMIN    =&gt; 'info@my.org',
                                SERVERS         =&gt; 3,
                                WORKERS         =&gt; 1,
                                DOCUMENT_ROOT   =&gt; '/opt/my/web',
                                DOCUMENTS       =&gt; {
                                                     '/index.html'    =&gt; 'WPages::index',
                                                     '/error.html'    =&gt; 'WPages::error',
                                                     '/style.css'     =&gt; 'WPages::style',
                                                     '/print.css'     =&gt; 'WPages::print',
                                                     '/404.html'      =&gt; 'WPages::error404',
                                                     '*'              =&gt; 'WPages::pageHandle',
                                                   },
                                ERROR_PAGES     =&gt; { 
                                                     '404' =&gt; '/404.html',      # embeded subroutine error
                                                     'ALL' =&gt; '/error.html',    # simple html file error
                                                   },
                                EXPIRATIONS     =&gt; { 
                                                     'image/jpg' =&gt; 86400,
                                                     'ALL' =&gt; 3600, 
                                                   },
                                PROC_PREFIX     =&gt; 'my:',
                                CHILD_START     =&gt; 'WControl::start_db',
                                CHILD_END       =&gt; 'WControl::stop_db',
                                LOG_METHOD      =&gt; 'WControl::logInfo',
                                DEBLOG_METHOD   =&gt; 'WControl::logDebug',
                                LOG_HEADERS     =&gt; 0,
                                LOG_PACKETS     =&gt; 0,
                                CGI_PATH        =&gt; '/cgi',
                                ENV_KEEP        =&gt; [ 'PERL5LIB', 'LD_LIBRARY_PATH' ],
                                NO_LOGGING      =&gt; 0,
                           );</pre>
<pre>
  $server-&gt;execute();</pre>
<p>
</p>
<hr />
<h1><a name="description">Description</a></h1>
<p>The WebIT embeded web server was created a long time ago to make a pure perl application that will interact 
directly with <em>Kannel</em>. The need was to relieve <em>Kannel</em> from the need to wait for the web server to run 
its scripts before going back to serve another SMS message. In this respect WebIT is a hack and can be 
configured to behave in a manner which is not according to the RFC's for HTTP. Yet, creating Perl applications 
with WebIT using embeded html pages as perl functions outperforms Apache with mod_perl installations.</p>
<p>For this reason I was asked by a few to release this code so that they can use it for their applications.</p>
<p>So even though WebIT is not complete (Workers and SSL not implemented yet) WebIT is already used by 
14 perl applications that I know of excluding my personal work.</p>
<p>To work with WebIT all you need to do is to create a new server object by giving to it the parameters
that you want, and then at any point in time call the execute method to run the server. The execute method 
returns only when the server has finished execution, and that can only be done by sending a TERM signal to 
the process.</p>
<p>Once the server has started it will fork the predefined number of servers and workers. Since workers are not 
implemented yet you are advised to ask for 0 workers on startup. From then on, WebIT will serve HTTP requests 
by using external files in a configured directory and/or internal pages served by perl subroutines. The code
of the cgi pages and subroutines is as you already know by Apache and mod_perl. You can use the CGI module to 
get the request parameters, print on the standard output to form the response to the caller, and print to 
standard error to log text to the logger of the server.</p>
<p>
</p>
<hr />

webdemo/test_site/pod.html  view on Meta::CPAN

connection. You can pass the actual key here as is. The value is first tested 
to see if it matches an existing file, and if not it will be used as an
actual key. (default is undef).
<strong>This feature is not implemented yet</strong></p>
</dd>
<dt><strong><a name="wait_response" class="item">WAIT_RESPONSE</a></strong></dt>

<dd>
<p>Directs the server to wait until a response is generated. If 0 server will 
close connection before running scripts or getting pages and returns 204  
(No Content) to client (default is 1 and the server will wait for responses)</p>
</dd>
<dt><strong><a name="no_wait_reply" class="item">NO_WAIT_REPLY</a></strong></dt>

<dd>
<p>The code to send when WAIT_RESPONCE is 0. (default is undef and 204 is returned)</p>
</dd>
<dt><strong><a name="immed_close" class="item">IMMED_CLOSE</a></strong></dt>

<dd>
<p>Close connection immediately after serving request. Ignored if WAIT_RESPONSE is 0. (default is 0)
If it is set to 0 the server will respect the client's request about the handling of the connection (might be
immediate close or keep open)</p>
</dd>
<dt><strong><a name="run_as_user" class="item">RUN_AS_USER</a></strong></dt>

<dd>
<p>The user under which the server should run as</p>
</dd>
<dt><strong><a name="run_as_group" class="item">RUN_AS_GROUP</a></strong></dt>

<dd>
<p>The group under which the server should run as</p>
</dd>
<dt><strong><a name="setup_env" class="item">SETUP_ENV</a></strong></dt>

<dd>
<p>Allow the server to setup the children environment. This requires some milliseconds for each request
served since the server will have to contruct the environment for each call. It you are not using the CGI 
module and you know what you are doing you can set this to 0-false and save some time for running requests
(default is 1)</p>
</dd>
<dt><strong><a name="env_keep" class="item">ENV_KEEP</a></strong></dt>

<dd>
<p>List of environment variables to keep for scripts. For normal execution all environment variables are cleared 
and CGI and embeded pages run in a clean environment. If however you need to preserve some, like database variables
you can specify their names here in an array, and they will be preserved for your scripts.</p>
</dd>
<dt><strong><a name="env_add" class="item">ENV_ADD</a></strong></dt>

<dd>
<p>Hash with environment variables and values to set for scripts. These environment variables and their values will be 
added to the environment of your CGI and embeded pages.</p>
</dd>
<dt><strong><a name="mime_types" class="item">MIME_TYPES</a></strong></dt>

<dd>
<p>Path and file where the server can find valid mimetypes. (default is /etc/mime.types)</p>
</dd>
<dt><strong><a name="embed_perl" class="item">EMBED_PERL</a></strong></dt>

<dd>
<p>Run perl CGI scripts inside the server, not in a separate process. Faster than Apache and mod_perl. (default is 0)</p>
</dd>
<dt><strong><a name="server_admin" class="item">SERVER_ADMIN</a></strong></dt>

<dd>
<p>The email of the server administrator. This text will appear in the environment variables of the CGI / embeded pages (default is empty)</p>
</dd>
<dt><strong><a name="document_root" class="item">DOCUMENT_ROOT</a></strong></dt>

<dd>
<p>The path where the site documents and scripts are stored. (default is undef)</p>
</dd>
<dt><strong><a name="documents" class="item">DOCUMENTS</a></strong></dt>

<dd>
<p>A hash of documents and their subroutines to execute within the server. This is 
used to create fully embeded web servers that respond to specific URL's using 
specific subroutines. A special page name '*' can be used to direct all unknown 
page requests to be directed to the subroutine of this special page.
Can be used in conjunction with and has precedence over DOCUMENT_ROOT (default is undef)</p>
</dd>
<dt><strong><a name="error_pages" class="item">ERROR_PAGES</a></strong></dt>

<dd>
<p>A hash with the site supplied error pages. It contains the error code as a key and
the page path within DOCUMENT_ROOT or DOCUMENTS of the page for the error. Alternatevly there can
be an entry with keyword ALL where all errors without a specific entry in the hash
will find their error pages. Error pages can be cgi's or plain html. (default is undef) 
For all error pages the server sets 4 extra environment variables. These are:</p>
<dl>
<dt><strong><a name="error_code" class="item">ERROR_CODE</a></strong></dt>

<dd>
<p>This contains the numeric value of the error, eg 404.</p>
</dd>
<dt><strong><a name="error_text" class="item">ERROR_TEXT</a></strong></dt>

<dd>
<p>This contains the text value of the error, eg Page not found.</p>
</dd>
<dt><strong><a name="error_uri" class="item">ERROR_URI</a></strong></dt>

<dd>
<p>This contains the URI that generated the error.</p>
</dd>
<dt><strong><a name="error_method" class="item">ERROR_METHOD</a></strong></dt>

<dd>
<p>This contains the method used to access the URI, eg POST</p>
</dd>
</dl>
<p>Along with all other environment variables used you can track all errors to their fullest detail, and handle 
them not just for display but for administrator notifications as well.</p>
</dd>
<dt><strong><a name="expirations" class="item">EXPIRATIONS</a></strong></dt>

<dd>
<p>A hash with expiration times. It contains the content type as a key and the expiration



( run in 0.751 second using v1.01-cache-2.11-cpan-71847e10f99 )