2% 3% Module dependencies. 4% 5 6:- use_module(library(http/thread_httpd)). 7:- use_module(library(http/http_dispatch)). 8 9% 10% Expose `app`. 11% 12 13:- module(app, [route/2,server/1,header/2,body/1]). 14 15% 16% Define a route. 17% 18 19route(Path, Handler):- 20 http_handler(Path, Handler, []). 21 22% 23% Start a server. 24% 25 26server(Port):- 27 http_server(http_dispatch, [port(Port)]). 28 29% 30% Add a header. 31% 32 33header(HeaderKey, HeaderValue):- 34 format('~s: ~s~n~n', [HeaderKey, HeaderValue]). 35 36% 37% Respond with body. 38% 39 40body(Text):- 41 format('~s~n', [Text])