File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ <html>
3+ <head>
4+ <script type="ml/global">
5+ type Async.session_data += Count of int
6+ </script>
7+ <script type="ml/prelude">
8+ let cookies, session = Session.check ~init:(fun _ -> Count 0) request
9+ let count =
10+ match Session.get_session_data session with
11+ | Count n -> n
12+ | _ -> -12
13+ | exception Not_found -> -100
14+ let _ = Session.set_session_data session (Count (count+1))
15+ </script>
16+ </head>
17+ <body>
18+ <h1>dynamic hello!</h1>
19+ <ul>
20+ <li> item 1 </li>
21+ <li> item 2 </li>
22+ <li> item 3 </li>
23+ <li> item 4 </li>
24+ <li> views: <ML>
25+ let _ = echo (string_of_int count);;
26+ let _ = echo (if count mod 2 = 0 then
27+ <p>even (<ML> ^ string_of_int count ^ </ML>)</p>
28+ else <p>odd</p>)
29+ </ML>
30+ </li>
31+ </ul>
32+ <a href="."> escape from this file </a>
33+ <br/>
34+ request: <ML>
35+ let _ = printf "%a" Request.pp request
36+ </ML>
37+ </body>
38+ </html>
You can’t perform that action at this time.
0 commit comments