GithubHelp home page GithubHelp logo

stairway2dvn / servr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yihui/servr

0.0 2.0 0.0 177 KB

A simple HTTP server in R

Home Page: http://cran.rstudio.com/package=servr

R 94.92% Makefile 0.43% HTML 4.66%

servr's Introduction

servr

Build Status

A simple HTTP server to serve files under a given directory based on the httpuv package.

You can install this package from CRAN (stable version) or RForge (development version):

install.packages('servr')  # stable version; use a CRAN mirror, or
install.packages('servr', repos = 'http://rforge.net')  # devel version

This package is licensed under GPL.

Serve static files

To some degree, this package is like python -m SimpleHTTPServer or python -m http.server. It may be used to serve:

  • googleVis charts (to solve the Flash security problem)
  • D3 charts which need to load JSON from local files (see also the animint package)
  • rCharts and samatha, etc

You can either run servr::httd() in an interactive R session, or run from command line:

# default: port 4321, do not launch browser
Rscript -e 'servr::httd()'

# open a web browser
Rscript -e 'servr::httd()' -b

# listen on port 4000
Rscript -e 'servr::httd()' -p4000

# pass arguments to the httd() function
Rscript -e 'servr::httd(,4000,TRUE)'

There is also a shell script under system.file('bin', package = 'servr'); if it is added to PATH, you can simply run

servr  # serve the current directory
servr -b  # launch the browser
servr -b -p4000  # change port to 4000

Serve dynamic documents

Besides httd(), there are functions jekyll(), rmdv1(), and rmdv2() in this package to serve HTML files generated from R Markdown documents (via knitr or rmarkdown). R Markdown documents can be automatically re-compiled when their HTML output files are older than the corresponding source files, and HTML pages in the web browser can be automatically refreshed accordingly, so you can focus on writing R Markdown documents, and results will be updated on the fly in the web browser. This is even more useful when you write R Markdown documents in the RStudio IDE, because the HTML files are displayed in the RStudio viewer pane, and you can put the source document and its output side by side.

Jekyll with servr and knitr

Serve package vignettes

The function vign() can be used to serve R Markdown/HTML package vignettes. The HTML output files are generated and displayed in the web browser so you can preview the vignettes, and they will be cleaned up after they are loaded in the web browser to make sure your source package is clean.

Daemonized server

All server functions be used in the daemonized mode, i.e., they can be non-blocking in the R session, which allows you to continue working in the R console after the server is launched. This mode can be set via the argument daemon = TRUE in most server functions. See ?server_config for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.