Created
August 18, 2020 22:20
-
-
Save kaiser185/254675d01c7227569d95ca9cfa1f92ad to your computer and use it in GitHub Desktop.
Logtalk Http Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- http_dispatch:http_handler(/, user:say_hi, []). | |
:- http_dispatch:http_handler(root(sam), user:say_hi_sam, []). %root(sam) -> GET -> <addr>/sam | |
say_hi(_Request) :- % (3) | |
http_server::say_hi(_Request). | |
say_hi_sam(_Request) :- | |
http_server::say_hi_sam(_Request). | |
:- object(http_server). | |
:- public(run/0). | |
run :- | |
{ thread_httpd:http_server( | |
http_dispatch:http_dispatch, | |
[port(8080)]) }. | |
:- public(say_hi/1). | |
say_hi(_Request) :- % (3) | |
format('Content-type: text/plain~n~n'), | |
format('Screw the World!~n'). | |
:- public(say_hi_sam/1). | |
say_hi_sam(_Request) :- % (3) | |
format('Content-type: text/plain~n~n'), | |
format('Hello Sam!~n'). | |
:- end_object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- use_module(library(http/thread_httpd), []). | |
:- use_module(library(http/http_dispatch), []). | |
:- initialization(( | |
logtalk_load(http_server) | |
)). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment