git.iko.soy/typeable/servant
on 0.2.2 help sign in
17 lines 863 B history raw
1# Examples
3## counter
5This example demonstrates a *servant* server that holds a shared variable (using a `TVar`) and exposes an endpoint for reading its current value and another one for increasing its current value by 1.
7In addition to that, it shows how you can generate the jquery-powered javascript functions corresponding to each endpoint, i.e one for reading the current value and one for increasing the value, and integrates all of that in a very simple HTML page. All these static files are served using the `serveDirectory` function from *servant*.
9To see this all in action, simply run:
11``` bash
12$ cabal run counter
13```
15And point your browser to [http://localhost:8080/index.html](http://localhost:8080/index.html).
17Copies of the generated javascript functions and of the generated docs are included in `www/api.js` and `counter.md` respectively.