Using locally-run self-configurable web server to implement Rich GUI for desktop applications in Perl. Stunnix Web Servers.

Locally-run web server for cross-platform GUI apps coded in Perl

Stunnix Web Server

This is S5-based presentation. If viewing in browser, use keyboard arrows to navigate between slides.

GUI apps in Perl: impossible :-(

If we want them to run on Windows, OS X and Linux:

  • GtkPerl seems to be only way to do it, rather complicated to install on Windows and OSX.
  • QtPerl is not maintained
  • WxPerl is a pain (since Wx is a pain to use and unreliable)

Why not run web-server locally?

We can use locally-run web server and web app to implement functionality

Concept (from user's point of view):

  • user clicks on some icon or shortcut
  • window appears (possibly browser window) with applcation in it
  • Once user finished working with app, he clicks some button like QUIT on the page - window disappears and RAM is freed from web server

How it should be implemented

How this can be implemented under the hood? When user clicks an icon, some wrapper:

  1. checks that server for that App is not running yet (otherwise go to step 4)
  2. finds free TCP port
  3. starts web server on free tcp port
  4. starts browser with showing some page of the site

What's special with this approach?

Web Server is run locally, so:

  • user doesn't need to be connected to Internet to work with app
  • nobody can connect to this web server from other computers - security is not important
  • transfer speed is at least 30Mb/sec
  • We can use a lot of multimedia due to speed and can make our app prettier than convenient apps

Why developer should love this?

  • web development is much cheaper than GUI app development
  • Product is cross-platform by definition
  • It's trivial to make such app a networked app (serving more than 1 user) - just ask web server to listen on 0.0.0.0, not 127.0.0.1
  • almost any existing serverside and client-side web code will work this way after trivial modifications (or as is)

Why user should love this?

  • Any dialog/page can be printed
  • Font size can be changed with a roll of a mouse wheel
  • Any piece of text can be copied to clipboard
  • custom skins can be used for UI (using functionality provided by the browser)
  • Multi-document interface is trivial to use (and implement)
  • There is a big chance that developer can make multi-client app and it will be cheap (since it's trivial for developer to implement it)

Why user should love this?

  • Any browser window can be resized
  • Developer can implement attractive UI since it's easy to do this with this technology
  • Advanced user or sysadmin can tailor .html templates to their needs (e.g. to fill default values)
  • Plugins and native support for auto form filling are available

Required for user's convenience:

  • Working as a non-root user
  • No need to do installation of web server, perl and other dependancies
  • Small response time, interactivity as close to usual GUI apps
  • Concurent use of products using this approach by the same user
  • Ability to quit product (e.g. to uninstall it immediately after trying :-) )

How Stunnix Perl Web Server was born

There was a need for cross-platform GUI for Stunnix Obfuscators (all written in Perl). 9 years ago it was impossible to implement in Perl using Gtk or Qt. So "locally-run web server for GUI" concept was born.

There were no good pure Perl web servers 9 years ago. Problems with existing ones (UNIX only/ cgi-only/ no POST/ one request per time). So Stunnix Perl Web Server was created (SPWS for short from here).

Features of SPWS

  • Satisfies all "convenience requirements" above.
  • Pure perl (5.004 or later)
  • Uses only modules shipped with perl
  • Doesn't need to install anything additional
  • Windows edition may include stripped Perl interpreter; on other platforms, system perl is used for running
  • Includes smart wrapper that finds free port and opens browser

Introduction to SAWS

Also SAWS was born, that used Apache codebase for web server core. Reasons:

  • Ability to code server-side logic in PHP and Python using mod_php, mod_python
  • More stability and features

Features of SPWS and SAWS

  • Work from directory with any name, including ones with spaces in names
  • No installation needed - extract to any directory and run from there
  • Works from read-only devices
  • Share same set of Perl wrapping code for configuring and starting web server and database server
  • Show tray icons on Windows and Mac - for stopping web server and reopening main page.

Features of SPWS and SAWS

  • Additional info about system is exported to scripts
  • Blocks Windows Firewall
  • Has web self-hosted configuration tool for developer -CDBuilder
  • Supports MySQL and SQLite as databases with proper initialization and database file handling

Details on Stunnix Advanced Web Server

Has all features of SPWS plus:

  • Supports HTTP over Named Pipes on Windows to avoid problems with Firewalls
  • Includes additional tools to implement apps conveniently - e.g. native file and directory selector
  • Ships with custom built of Portable Firefox (no menubar, no toolbar, supports HTTP over Named Pipes on Windows)
  • Works from read-only devices
  • Allows static files to be encrypted
  • Supports mod_perl, mod_php, mod_python, mod_rewrite, mod_proxy and all Apache modules.

What applications to implement

  • Interactive catalogues on CDs, photoalbums
  • Training and learning materials on CDs/DVDs or as downloadable apps
  • Downloadable site snapshots for users with bad connectivity
  • small CRM systems
  • corporate apps
  • same as for Rich Internet Apps

Who uses this approach?

Stunnix uses SPWS for Obfuscators (for C/C++, JavaScript, VBScript, Perl). They are implemented completely in Perl, both UI and backend.

Stunnix customers.

Besides Stunnix customers, we know only about HP/Compaq:

A control panel for HP printers (e.g. HP LaserJet 1018) for Windows is implemented as locally-run Tomcat site.

Problems when using this approach?

  • Parts of brower's UI that are visible sometimes confuse users. Special web browser can be included with the server.
  • Competitors can study or borrow server-side code from locally-run web site. One can use Stunnix Perl-Obfus for obfuscation of Perl code and IonCube PHP Encoder for PHP code.

Questions?