Created
April 6, 2020 23:11
-
-
Save randy3k/de833f37b2e3ec931fcca2448cd83d3e to your computer and use it in GitHub Desktop.
preview private github repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httpuv) | |
library(httr) | |
library(stringr) | |
app <- list( | |
call = function(req) { | |
paths <- str_split(req$PATH_INFO, "/")[[1]] | |
owner <- paths[2] | |
repo <- paths[3] | |
path <- str_c(paths[4:length(paths)]) | |
r <- GET( | |
str_glue("https://raw.githubusercontent.com/{owner}/{repo}/master/{path}"), | |
add_headers(Authorization = paste("token", Sys.getenv("GITHUB_PAT"))) | |
) | |
list( | |
status = 200L, | |
headers = list( | |
"Content-Type" = "text/html" | |
), | |
body = content(r, as = "text") | |
) | |
} | |
) | |
server <- runServer("0.0.0.0", 9454, app) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Visit the page using http://localhost:9454/{owner}/{repo}/{file}