small but scheme-typically powerful web application framework
- initialises web applications, starts a server and provides optional modules for some features commonly needed for web projects
- similar perhaps to express.js
- status: should work. maintained as of 2019-04
(import (sph web app) (sph web app http))
(define (app-respond request) (respond "test"))
(define swa-app (swa-app-new app-respond))
(swa-start swa-app #f #f swa-server-guile)
put the above in a file example.scm
then
guile example.scm
see
listening on 127.0.0.1:6500
exit with ctrl+c
then take a browser and go to
http://127.0.0.1:6500
- reads configuration files, starts a server, passes request objects to handler procedures and transmits response objects
- protocol agnostic core: socket -> web-app -> socket
- pluggable server (thread-pool scgi, fibers scgi, direct http, none for testing ...)
- derivative environment configuration files in an s-expression format
- mostly functional, avoids side-effects. no "set!" used
- basic routing on any request property and url pattern matching
- the scgi servers are for use with a proxy like nginx for https, automatic chunked-encoding, fast file transfers, keep-alive, websockets, load-balancing, caching, general http robustness and more
- optional modules
- http requests/responses
- templating with s-expression versions of xml (sxml), css (plcss) and javascript (sescript)
- asset processing: transcompilation, bundling, minification, compression, formatting, etc
- fast
- plain vectors as records for request and response objects
- response objects can have procedures that send data while it is generated
- requests have little overhead as little data has to be prepared
an example project that combines sph-web-app with sph-web-publish: sph-info
- install all dependencies
- download
- alternatives: git clone
- unpack the downloaded archive. for example with "tar -xf sph-web-app.tgz" (-x for extract, -f for the input file)
cd sph-web-app
su root
./exe/install
the installer is a shell script that copies files and sets filesystem permissions. the script can take one argument, the path prefix to install to
for example using aurget
aurget -S --deps sph-web-app-git