Gentle Introduction to POW SJS

From PlainOldWebserver

Jump to: navigation, search

Back to Top
Next: AJAX Chat Application -->

[edit] A quick hello world

1. Download the extension from the Mozilla Addons site.

2. Restart Firefox.

3. A couple of seconds after restart, the welcome page appears (http://localhost:6670/). Drag the file link to your desktop. This links to a local folder.

Drag the directory to your desktop.
Drag the directory to your desktop.

4. Create a text file (Using Notepad or vi or the like) named test.sjs and add the following text.

  <?sjs
     document.write("Hello world!");
  ?>

5. Save this into the POW directory.

6. Type localhost:6670/test.sjs into the location bar.

Hello World result in a browser.
Hello World result in a browser.

The .sjs extension allows the server-side Javascript to run. Other acceptable file types include .html, .gif, .jpg and any other file-type.

What can SJS do that client side Javascript cannot? Why bother with this silliness?

POW and SJS allow the browser to listen for connections, save to a database and open files on the local file system. It allows applications that I do not have time to code, such as file-sharing or instant messaging applications. Breadcrumbs is another example of an application that could only be written with POW-SJS.

Next: AJAX Chat Application -->
Personal tools
Navigation