Skip to content

Instantly share code, notes, and snippets.

@Xevion
Created May 9, 2022 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xevion/f27c1186898e3bfeee5185d1d98eb74f to your computer and use it in GitHub Desktop.
Save Xevion/f27c1186898e3bfeee5185d1d98eb74f to your computer and use it in GitHub Desktop.
library(beakr)
# Create a new beakr server
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.")
}) %>%
# Handle any errors with a JSON response
handleErrors() %>%
# Start the server on port 25118
listen(host = "127.0.0.1", port = 25118)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment