summaryrefslogtreecommitdiffstats
path: root/builtin-programs/web/camera-frame.folk
blob: 598b2a980c10e7d5d0cfaa8060460edd2d08eab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
When the jpeg library is /jpegLib/ {
    Wish the web server handles route {/camera-frame} with handler {
        set camera [dict getdef $QUERY camera /any/]
        ForEach! camera $camera has jpeg frame /jpeg/ at timestamp /any/ {
            set data [$jpegLib jpegData $jpeg]
            set fsize [string bytelength $data]
            break
        }
        if {![info exists data]} {
            error "camera-frame: No valid camera frame found (for $camera)"
        }

        dict create statusAndHeaders "HTTP/1.1 200 OK
Connection: close
Content-Type: image/jpeg
Content-Length: $fsize\n\n" \
            body $data
    }
}