MazamaScience/beakr

serveStaticFiles() fails to server .html

Closed this issue · 1 comments

This version of beakr serves .png and .txt files fine. But when asked for a .html file it always returns "3c".

Here is a script that reproduces the error:

# ===== Create output files ====================================================

if ( FALSE ) {

  # Create a .txt file in temp directory
  dir.create("./output")
  textString <-
"
<html>
<body>
<h1>Hi!</h1>
</body>
</html>
"
  cat(textString, file = "output/hi.txt")
  cat(textString, file = "output/hi.htm")
  cat(textString, file = "output/hi.html")

}

# ===== beakr pipeline =========================================================

library(beakr)

# beakr pipeline
newBeakr() %>%

  # Respond to GET requests at the "/hi" route
  httpGET(path = "/hi", function(req, res, err) {
    print("Hello, World!")
  }) %>%

  # Respond to GET requests at the "/bye" route
  httpGET(path = "/bye", function(req, res, err) {
    print("Farewell, my friends.")
  }) %>%

  # Host the directory of static files
  serveStaticFiles() %>%

  # Start the server on port 25118
  listen(host = "127.0.0.1", port = 25118)


# * http://localhost:25118/output/hi.txt  -- works
# * http://localhost:25118/output/hi.htm  -- FAILS: returns "3c"
# * http://localhost:25118/output/hi.html -- FAILS: returns "3c"

Resolved in version 0.4.3.