example:-
testinput.pl
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_error)).
:- use_module(library(http/html_write)).
:- use_module(library(http/http_parameters)).
:- use_module(testoutput).
:- http_handler(root(test), web_form, []).
server(Port) :-
http_server(http_dispatch, [port(Port)]).
web_form(_Request) :-
reply_html_page(
[title('e-TEST')],
[
form([action='/landing', method='POST'], [
p([], [
label([for=name],'Please select: '),
input([name=test, type=radio, value="one"]),"TEST 1",
input([name=test, type=radio, value="two"]),"TEST 2"
]),
p([], input([name=submit, type=submit, value='Submit'], []))
])]).
:- http_handler(root(landing), user_input, []).
user_input(Request):-
http_parameters(Request,
[ test(Input, [])
]),
format('Content-type: text/html~n~n', []),
format('<table border=1>', []),
format('<tr>', []),
format('<td>', []),write("Your Input"),nl,format('</td>', []),
format('<td>', []),format('<b>', []),write(Input),nl,format('</b>', []),format('</td>', []),
format('</tr>', []),
format('</table>', []),
test_output(Input).
testoutput.pl
%testoutput.pl
:- module(testoutput,
[
test_output/1
]).
test_output(X):-
writeln(X),
output.
output:-
my_list(_, Output),
writeln(Output),
fail.
my_list(1, 'test 1').
my_list(2, 'test 2').
my_list(3, 'test 3').
my_list(4, 'test 4').
my_list(5, 'test 5').
my_list(6, 'test 6').
my_list(7, 'test 7').