You may remember the days of html, dynamic or not, php3, funny, and funky under construction 🚧… Ah!… While the visual aesthetic can remain in the past, the ease, and simplicity to create, show, and tell used to be simpler, easier, and more fun. Petit Cloud is a demonstration that the 90s, early 00s workflow can be implemented for fun with our favorite material.
Any resemblance to competitor technology is wholly, and fully coincidental.
The interface can not be simpler. Given a
www.scm with an exported procedure
main, it should be possible to do the following:
#;sh> petit-cloud deploy www.example www.scm
Here the intent is to deploy the code of
WWW.SCM including dependencies, to
WWW.EXAMPLE, both are parameter, and may be changed at will.
At this point jumping to
https://www.example/ should display page associated with the root path.
MAIN is the request handler. It takes as argument the HTTP request parts:
It is expected to return three values:
BODY is always a bytevector.
headers is an list mapping a symbol to a string.
URL is the complete Universal Ressource Location including scheme, host, path, query string, and fragment as a list. Here is a possible value for
equal? url (list 'https (assert (list "example" "www") (list "path" "to" "object") (list (cons 'q "freedom")) (list)))) (
A hello world
MAIN can look like:
define main (lambda (method url headers body) (cons method path) (match (values 200 (() ("text/plain")) '((content-type . "Hello schemer!"))) (string->utf8 else (values 404 ("text/plain")) '((content-type . "Nothing here, error 404!")))))) (string->utf8
Furthermore, a couple of procedure should be made available:
www-form-urlencoded-readthat helps with forms;
jsonifythat takes a scheme objects as argument, and returns the bytevector made of its JSON representation;
Go back, rest, think, and eat your vegetables.