R built in Web server

前端 未结 3 1474
广开言路
广开言路 2021-02-14 18:37

Since R 2.13, R comes with a built-in web server. Is there a simple way to create a local web server using R with a custom port number?

In python it will be (to use \"

3条回答
  •  长情又很酷
    2021-02-14 19:23

    It looks like servr might be what you're looking for these days.

    From github:

    To some degree, this package is like python -m SimpleHTTPServer or python -m http.server.

    https://github.com/yihui/servr

    https://cran.rstudio.com/web/packages/servr/index.html

    Example code

    writeLines("

    Hi

    ", "index.html") # install.packages("servr") library(servr) servr::httd() # createTcpServer: address already in use # To stop the server, run servr::daemon_stop(2) or restart your R session # Serving the directory /Users/st/R/localhost at http://127.0.0.1:7826

    Place the address in the browser: http://127.0.0.1:7826

提交回复
热议问题