-
Notifications
You must be signed in to change notification settings - Fork 40
/
resource_by_mailman.pl
47 lines (37 loc) · 1.21 KB
/
resource_by_mailman.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_error)).
% http_reply_from_files is here
:- use_module(library(http/http_files)).
% http_404 is in here
:- use_module(library(http/http_dispatch)).
% html generation and mailman
:- use_module(library(http/html_write)).
% Finally! now we know why Annie keeps doing this
%
:- multifile http:location/3.
:- dynamic http:location/3.
http:location(files, '/f', []).
% this serves files from the directory assets
% under the working directory
:- http_handler(files(.), serve_files, [prefix]).
serve_files(Request) :-
http_reply_from_files('assets', [], Request).
serve_files(Request) :-
http_404([], Request).
server(Port) :-
http_server(http_dispatch, [port(Port)]).
:- http_handler(root(.), a_handler, []).
a_handler(_Request) :-
reply_html_page(
[title('a page with style'),
\html_receive(css)],
[h1('A Page That Glitters'),
\css('/f/specialstyle.css'),
p('This para is green')]).
css(URL) -->
html_post(css,
link([ type('text/css'),
rel('stylesheet'),
href(URL)
])).