-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path2_DataSummary.R
More file actions
40 lines (32 loc) · 1.31 KB
/
2_DataSummary.R
File metadata and controls
40 lines (32 loc) · 1.31 KB
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
app <- function(env){
req <- Rook::Request$new(env)
res <- Rook::Response$new()
# 'POST' returns a list of all elements collected
# from a form.
userData <- req$POST()
if (!is.null(userData$desc)){
# There's no check to see if the user actually uploaded a file
# how and where would up check to see if this occurs?
#
# FYI, an uploaded file input element contains a list with
# four elements: 'filename' = original file name, 'tempfile' =
# location of temporary file, 'content_type' = type of file,
# and 'head' = mime time header for file portion of message
d <- read.csv(userData$csvdat$tempfile)
# Read the help file for the Utils object to learn
# about 'unescape'.
res$write(c("<p>",userData$desc,"</p>"))
# Rather that printing the raw data, try capturing the output
# of summary.
res$write("<pre>")
res$write(paste(capture.output(print(d)),collapse="\n"))
res$write("</pre>")
} else {
res$write('Uploade Data Summary and File:<br>')
res$write('<form enctype="multipart/form-data" method="POST">')
res$write('<textarea rows="10" cols="80" name="desc"></textarea><br>')
res$write('<input type="file" name="csvdat"><br>')
res$write('<input type="submit" name="Submit"></form>')
}
res$finish()
}