-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
41 lines (36 loc) · 1.1 KB
/
app.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
library(shiny)
library(httpuv)
# Define the path to the directory containing your Doom game files
# doom_directory <- "./doom-wasm/src"
doom_directory <- "./doom-compiled"
# Start a server to serve Doom files
startServer("127.0.0.1", 1234, list(
call = function(req) {
filePath <- paste0(doom_directory, req$PATH_INFO)
if (file.exists(filePath)) {
return(list(
status = 200,
headers = list(
"Content-Type" = "text/html"
),
body = readBin(filePath, "raw", file.info(filePath)$size)
))
} else {
return(list(
status = 404,
headers = list(
"Content-Type" = "text/html"
),
body = "File not found"
))
}
}
))
ui <- fluidPage(
tags$h1("Doom in Shiny"),
tags$p("Space: fire; E: open door; up/down/left/right: move; 1-4: change weapon; Esc: release mouse/go to menu; F: full screen"),
tags$iframe(style = "width:850px; height:640px;", src = "http://127.0.0.1:1234/index.html")
)
server <- function(input, output, session) { }
# Run the Shiny app
shinyApp(ui, server, options = list(port = 4321))