Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 54 lines (35 sloc) 1.237 kb
961926f @klacke ""
authored
1 <erl>
2 out(A) -> file:read_file([A#arg.docroot, "/EXHEAD"]).
3 </erl>
4
5 <h2>Talking to the server</h2>
6
7 Since we are running in the same process as the webserver itself, it is
8 easy for us to interact with the webserver itself from a yaws script.
7811247 @vinoski whitespace cleanup
vinoski authored
9 The following is an example which produces a statistics report
10 from the webserver. We call the server
961926f @klacke ""
authored
11
12 The absoluteley most simple example is a HTML file which doesn't contain
7811247 @vinoski whitespace cleanup
vinoski authored
13 any embedded erlang code at all.
961926f @klacke ""
authored
14
15
16 <erl>
7811247 @vinoski whitespace cleanup
vinoski authored
17 out(A) ->
961926f @klacke ""
authored
18 {ok, B} = file:read_file([A#arg.docroot, "/stats_ex1.yaws"]),
19 {ok, ["<xmp> \n", B, "</xmp\n>"]}.
20 </erl>
21
22 <br>
23 Since the file has the suffix <tt>.yaws</tt>, the file will be processed
24 by the Yaws dynamic compiler, but since no embeddded erlang code is found,
25 the data from the file will be delivered untouched.
26 <br>
27
28 <h2> Hello world again </h2>
29
30 The file <a href="simple_ex2.yaws">simple_ex2.yaws</a> contains the following
31 HTML code.
32 <br>
33 <erl>
7811247 @vinoski whitespace cleanup
vinoski authored
34 out(A) ->
961926f @klacke ""
authored
35 {ok, B} = file:read_file([A#arg.docroot, "/simple_ex2.yaws"]),
36 {ok, ["<xmp> \n", B, "</xmp\n>"]}.
37 </erl>
38
39 The file has one very simple function which just returns a tuple
40 <tt>{ok, String} </tt>
41 <br>
42 The String will be substituted into the delivered HTML data instead of the
43 Erlang code.
44
45
46
47
48
49
50
51
52
53 </html>
Something went wrong with that request. Please try again.