blob: de8f0e7eb6c306f0f5f162e35a22e6c346dda370 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
## Note that this code is leftover from the beginning of this project,
## which was originally a CGI document viewer that grew into a HTTP
## server instead, but I plan to implement this as a module.
## This is not at all supposed to be used right now.
variable directories {articles test-one}
### Content
proc run {request_target} {
}
append http::content [html::start Lame!]
## If directory is not queried,
if { ([lsearch -exact [dict keys $query] "directory"] eq -1) || ([lsearch -exact $directories [dict get $query directory]] eq -1 )} {
append http::content "Utter failure."
append http::content [html::end]
http::respond
exit
}
set directory [dict get $query directory]
## If document is not queried, or does not exist in our directory,
set documents [exec ls -Q $directory]
if { ([lsearch -exact [dict keys $query] "document"] eq -1) || ([lsearch -exact $documents [dict get $query document]] eq -1 ) } {
foreach a $documents {
append http::content [html::link $a "?directory=$directory&document=$a"]
}
append http::content [html::end]
http::respond
exit
}
## Open file
set file [open "$directory/[dict get $query document]" r]
## Output lines
while {[gets $file line] != -1} {
append http::content "$line <br> "
}
append http::content [html::end]
|