Hello world/Web server: Difference between revisions

(Added prolog)
Line 790:
 
=={{header|Prolog}}==
{{works with|SWI- Prolog}}
{{works with|YAP}}
<lang Prolog>%includes needed to start server
 
<lang Prolog>% The following modules are used in the main module to start a server.
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
 
% needed for each page
% The following module is used in every module that describes a page.
:- use_module(library(http/html_write)).
 
%start the server
% Main entry point: starts the server on port 8080.
server :-
server :- http_server(http_dispatch, [port(8080)]).
 
%define aDefines the handler onfor the /root URI /.
:- http_handler('/', say_goodbye, []).
%define the page.
say_goodbye(_Request) :-
reply_html_page(
[title('Howdy')],
[h1('Goodbye, World!')]).
</lang>
 
% Defines the actual page content.
% In this case we're returning a page with the title "Howdy" and the content,
% wrapped in <h1></h1> tags, "Goodbye, World!".
say_goodbye(_Request) :- reply_html_page([title('Howdy')],
[h1('Goodbye, World!')]).</lang>
 
=={{header|PureBasic}}==