-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathserver.pl
63 lines (48 loc) · 1.73 KB
/
server.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
:- module(pengines_server,
[ server/1 % ?Port
]).
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_path)).
:- use_module(library(http/http_authenticate)).
:- use_module(library(http/http_server_files)).
:- use_module(lib/admin/change_passwd).
/** <module> Pengines Web Server
*/
:- multifile
user:file_search_path/2,
http:location/3.
:- dynamic
user:file_search_path/2.
:- prolog_load_context(directory, Dir),
asserta(user:file_search_path(app, Dir)).
user:file_search_path(www, app(www)).
user:file_search_path(apps, app(apps)).
http:location(apps, root(apps), []).
:- http_handler(apps(.), serve_files_in_directory(apps), [prefix]).
:- http_handler(root(.), serve_files_in_directory(www), [prefix]).
:- http_handler(root(tutorial), http_reply_file('www/tutorial.html', []), []).
:- http_handler(root(admin/'server.html'),
http_reply_file('www/admin/server.html', []),
[authentication(basic(passwd, admin))]).
:- http_handler(root(admin/'applications.html'),
http_reply_file('www/admin/applications.html', []),
[authentication(basic(passwd, admin))]).
:- http_handler(root(admin/statistics),
http_reply_file('www/admin/statistics.html', []), []).
:- http_handler(root(admin/'account.html'),
http_reply_file('www/admin/account.html', []),
[authentication(basic(passwd, admin))]).
:- http_handler(root(admin),
http_redirect(moved_temporary, root(admin/'server.html')), []).
:- http_handler(/,
http_redirect(moved_temporary, root(docs/'index.html')), []).
%% server(?Port) is det.
%
% Start the web-server on Port.
server(Port) :-
check_passwd(passwd),
http_server(http_dispatch,
[ port(Port),
workers(16)
]).