servant/servant-js/examples
Alex Mason 6462804f52 Merge branch 'master' of https://github.com/haskell-servant/servant into servant-dates
# Conflicts:
#	servant-server/servant-server.cabal
#	servant-server/src/Servant/Server/Internal.hs
#	servant-server/test/Servant/ServerSpec.hs
#	servant/servant.cabal
#	servant/src/Servant/API.hs
2016-09-02 12:53:04 +10:00
..
www Merge pull request #173 from freezeboy/axios 2015-07-29 14:10:41 +02:00
counter.hs Merge branch 'master' of https://github.com/haskell-servant/servant into servant-dates 2016-09-02 12:53:04 +10:00
counter.md rename servant-jquery to servant-js, Servant.JQuery to Servant.JS 2015-07-22 19:25:02 +02:00
README.md rename servant-jquery to servant-js, Servant.JQuery to Servant.JS 2015-07-22 19:25:02 +02:00

Examples

counter

This 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.

In 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.

To see this all in action, simply run:

$ cabal run counter

And point your browser to http://localhost:8080/index.html.

Copies of the generated javascript functions and of the generated docs are included in www/api.js and counter.md respectively.