次のような HTML フォームがあります。
<form action="test" method="post">
<input name="first_name" type="text"/>
<input name="last_name" type="text" />
<input name="age" type="text" />
<input type="submit" value="Send"/>
</form>
PHP、ASP、JSP などの他の手続き型プログラミング言語と同様に、入力フィールドの値を取得して画面に出力するにはどうすればよいですか?
次の方法で問題を解決しようとしました。
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- http_handler(root(test), reply, []).
:- http_handler('test', reply, []).
server(Port) :-
http_server(http_dispatch, [port(Port)]).
reply(Request) :-
member(method(post), Request), !,
http_read_data(Request, Data, []),
format('application/x-www-form-urlencoded', []),
format(Data).
500
これは、コードのエラー (内部サーバー エラー)に過ぎません。