SWI-Prolog で、Web サーバーを立てる
1434 ワード
サーバーのプログラムです。
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
Author And Source
この問題について(SWI-Prolog で、Web サーバーを立てる), 我々は、より多くの情報をここで見つけました https://qiita.com/ekzemplaro/items/8987626d3dd0cbaaaba4著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .