summaryrefslogtreecommitdiff
path: root/web/src/cgi.tcl-1.10/example/image.cgi
blob: d23ec344d18dfbfa6ab90e315d6b1767cf1b9d66 (plain)
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
#!/depot/path/tclsh
# See description below.

package require cgi

cgi_eval {
    source example.tcl
    cgi_input

    describe_in_frame "raw image" "This CGI script generates a raw
    image.  The script could be much more complicated - the point is
    merely to show the framework.  (The picture is of the US National
    Prototype Kilogram. It is made of 90% platinum, 10% iridium. It
    was assigned to the US in 1889 and is periodically recertified and
    traceable to [italic "The Kilogram"] held at
    [url "Bureau International des Poids et Measures" http://www.bipm.fr" $TOP]
    in France.)"

    # ignore the junk above this line - the crucial stuff is below

    cgi_content_type "image/jpeg"

    set fh [open $DATADIR/kg.jpg r]
    fconfigure stdout -translation binary
    fconfigure $fh    -translation binary	
    fcopy $fh stdout
    close $fh
}