summaryrefslogtreecommitdiffstats
path: root/builtin-programs/web/program.folk
blob: 11780baae5a66e115d2e63c6fdb899ae5c6ccf3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Wish the web server handles route {/program/(.*)$} with handler {
    set programName $1
    set match [QueryOne! $programName has program code /programCode/]
    if {$match eq ""} {
        html "<html><body>Program not found: [htmlEscape $programName]</body></html>"
        return
    }

    html [subst {
        <html>
        <head>
            <title>[htmlEscape $programName]</title>
            <link rel="stylesheet" href="/style.css">
        </head>
        <body>
        <h1>[htmlEscape $programName]</h1>
        <pre><code>[htmlEscape $match(programCode)]</code></pre>
        </body>
        </html>
    }]
}