-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude-relative-url.qmd
More file actions
57 lines (47 loc) · 1.1 KB
/
include-relative-url.qmd
File metadata and controls
57 lines (47 loc) · 1.1 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
title: "Embed file next to R shinylive app"
format:
html:
resources:
- shinylive-sw.js
- fruit-data.csv
filters:
- shinylive
---
:::callout-important
This approach does **not** work as the `shinylive` app does not get the local file data attached.
:::
```{shinylive-r}
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.R
library(shiny)
ui <- fluidPage(
titlePanel("Hello Shiny!"),
h3("Relative URL"),
verbatimTextOutput("urlText"),
h3("Downloaded Data by Relative URL"),
verbatimTextOutput("retrievedData")
)
server <- function(input, output, session) {
current_url <- function() {
paste0(
session$clientData$url_protocol, "//",
session$clientData$url_hostname, ":",
session$clientData$url_port,
session$clientData$url_pathname
)
}
output$urlText <- renderText({
paste0(current_url(), "Hi!")
})
output$retrievedData <- renderText({
"hi"
#read.csv(paste0(current_url(), "fruit-data.csv"))
})
}
# Create Shiny app ----
shinyApp(ui = ui, server = server)
```