Jan Burse, erstellt 24. Feb 2019
* Prolog code for the multimedia hello HTTP server.
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies GmbH makes no warranties
* regarding the provided information. XLOG Technologies GmbH assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies GmbH.
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies GmbH. If the company was not the originator of some
* excerpts, XLOG Technologies GmbH has at least obtained the right to
* reproduce, change and translate the information.
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
* Jekejeke is a registered trademark of XLOG Technologies GmbH.
* dispatch(O, P, R, S):
* The predicate succeeds in dispatching the request for object
* O, with path P, with request R and the socket S.
% dispatch(+Object, +Spec, +Request, +Socket)
dispatch(_, '/example04/piglet.gif', Request, Session) :- !,
http:dispatch(Object, Spec, Request, Session).
% dispatch_hello(+Request, +Socket)
% handle_hello(+Atom, +Socket)
% send_hello(+Atom, +Socket)
response_text(200, ['Content-Type'-'text/html; charset=UTF-8'], Response),
write(Response, ' <center><img src="piglet.gif">\r\n'),
write(Response, '<h1>Happy New Year 2019, '),
% html_begin(+Stream, +Atom)
write(Response, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r\n'),
write(Response, ' <head>\r\n'),
write(Response, ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r\n'),
write(Response, ' <meta name="viewport" content="width=device-width, initial-scale=1.0">\r\n'),
write(Response, ' </head>\r\n'),
write(Response, ' <body>\r\n').
write(Response, ' </body>\r\n'),
% ?- run_http(example04/hello, 8085), write('.'), flush_output, fail; true.
% Point browser to: http://localhost:8085/example04/hello.jsp?name=Fritz