-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathserver.R
66 lines (52 loc) · 1.67 KB
/
server.R
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
57
58
59
60
61
62
63
64
65
66
library(shiny)
library(shinyjs)
library(shinyURL)
credentials <- list("test" = "202cb962ac59075b964b07152d234b70")
shinyServer(function(input, output) {
shinyURL.server()
USER <- reactiveValues(Logged = FALSE)
observeEvent(input$.login, {
if (isTRUE(credentials[[input$.username]]==input$.password)){
USER$Logged <- TRUE
} else {
show("message")
output$message = renderText("Invalid user name or password")
delay(2000, hide("message", anim = TRUE, animType = "fade"))
}
})
output$app = renderUI(
if (!isTRUE(USER$Logged)) {
fluidRow(column(width=4, offset = 4,
wellPanel(id = "login",
textInput(".username", "Username:"),
passwordInput(".password", "Password:"),
div(actionButton(".login", "Log in"), style="text-align: center;")
),
textOutput("message")
))
} else {
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
shinyURL.ui()
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
}
)
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})