Pl-web is a small http application server that builds on the original GUI but with some things thrown out and a few added.
The following is included out of the box:
- File based sessions.
- File uploads.
- Static loading/downloading of certain file types.
- A small library of HTML drawing functions, also based on the original GUI functions.
To test first download the ext library into your picolisp folder, then do the same with pl-web.
Then launch with: ./pil pl-web/demo-app/main.l -go
Browse to: http://localhost:8080/login/
Static loading: http://localhost:8080/public/test.html
The websockets stuff is based on Jose I. Romeros' socket section of web.l. It's basically a copy paste with the following additions:
Routing: perform action / send to all people tagged with a specific tag, specific id or a specific id only if they're tagged with a specific tag (see below). Note that Redis is a required dependency for the socket routing to work, it depends on the pub / sub functionality. Simply run apt-get install redis-server on Ubuntu 14.04.
Authentication: lock down a certain action for a specific tag, only a client with the correct key will be able to execute.
Usage / Test:
1.) sudo apt-get install redis-server 2.) Start the server in your picolisp directory: pil pl-web/ws-demo/main.l -go
3.) Launch pl-web/ws-demo/index.html in a browser, open the browser console.
4.) Run the following:
(load "lib.l" "ext.l" "ext/base.l" "pl-web/pl-wsclient.l") (setq Ws (new '(+WsClient) "localhost" 9090 "/action/send/tag/chat/key/plclient/id/anne/")) (send> Ws "hello anne from pl") (bye)
Note the URL: /action/send/tag/chat/key/plclient/id/anne/, let's look at a few alternatives and their results:
/action/send/tag/chat/, in this case nothing will show in the browser console since the key is missing, if the chat/send combo had not bee locked down (see source of pl-web/ws-demo/main.l) the message would've gone out to all clients tagged with chat.
/action/send/tag/chat/key/plclient/, works, message goes out to all clients tagged with chat since the key is present.
/action/send/tag/chat/key/plclient/id/anne/, also works, anne is tagged with chat (see source of pl-web/ws-demo/index.html).
/action/send/tag/chat/key/plclient/id/john/, anne will not get this message as it goes out to john (or not at all if there is no client with that tag/id combination).
/action/send/id/anne/, works, the message will appear in the browser console. We're only using simple examples here, in your actual application you will replace anne and john with unguessable session ids.