サーバーのプログラムです。
helloweb.pl
# ! /usr/bin/swipl -f -q
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
server(Port) :-
http_server(http_dispatch, [port(Port)]).
:- http_handler(/, say_hi, []).
say_hi(_Request) :-
format('Content-type: text/html~n~n'),
format('Hello World! Oct/14/2018<p />~n'),
format('こんにちは。 今日は、10月14日です。<p />~n').
サーバーの実行
server(8000). とキーイン
$ ./helloweb.pl
?- server(8000).
true.
?-
ブラウザーで、 http://localhost:8000 にアクセス
サーバーを終了される時は、次のようにキーイン
halt.
次のバージョンで確認しました。
$ swipl --version
SWI-Prolog version 7.6.4 for x86_64-linux