Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexvpickering/handlr
R as a backend for web apps.
https://github.com/alexvpickering/handlr
opencpu r rapache shiny
Last synced: 3 months ago
JSON representation
R as a backend for web apps.
- Host: GitHub
- URL: https://github.com/alexvpickering/handlr
- Owner: alexvpickering
- License: other
- Created: 2018-01-12T23:34:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-07T20:35:53.000Z (over 6 years ago)
- Last Synced: 2024-05-21T02:53:13.756Z (6 months ago)
- Topics: opencpu, r, rapache, shiny
- Language: R
- Homepage:
- Size: 35.2 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# handlr
`handlr` makes R functions available as API endpoints. It is the less opinionated cousin of [OpenCPU](https://github.com/opencpu/opencpu).
#### Shared Features with OpenCPU
* Built on Apache2 and rApache
* Each request handled in seperate R fork
* Borrows code e.g. for parsing http requests#### Distinguishing Features
* Doesn't expose your R code through GET requests
* You decide what R functions can be run
* Easy user management with [`authr`](https://github.com/alexvpickering/authr)# Getting Started
Assumes Ubuntu 16.04. See the [wiki](https://github.com/alexvpickering/handlr/wiki) for a more thorough intro and [`authr`](https://github.com/alexvpickering/authr) for user management.
Install Apache2, rApache, and create an `entry.R` file that rApache will run:
```
sudo apt update
sudo apt install apache2 -ysudo add-apt-repository ppa:opencpu/rapache -y
sudo apt-get update
sudo apt-get install libapache2-mod-r-base -ysudo mkdir /var/www/R
sudo touch /var/www/R/entry.R
sudo vi /var/www/R/entry.R
```Type `i` to insert then paste the following:
```R
setHeader(header = "X-Powered-By", value = "rApache")# functions exported by 'packages' can be used as endpoints
packages <- c('your_package')handlr::handle(SERVER, GET, packages)
```
Save (type `esc:wq` then hit enter). Now create an example Apache2 site that will run `entry.R` for incomming http requests:```
sudo touch /etc/apache2/sites-available/example.conf
sudo vi /etc/apache2/sites-available/example.conf
```Type `i` to insert, then paste the following:
```apache
LoadModule R_module /usr/lib/apache2/modules/mod_R.soSetHandler r-handler
RFileHandler /var/www/R/entry.R```
Enable the example site:
```
sudo a2ensite example
sudo service apache2 reload
```Save and exit as before. Install `handlr` and `your_package`, making sure they will be available to the `www-data` user that Apache2 runs under:
```R
# devtools dependencies
sudo apt install libssl-dev
sudo apt install libcurl4-openssl-devsudo R
.libPaths('/usr/local/lib/R/site-library')install.packages('sys', configure.vars = 'NO_APPARMOR=1')
install.packages('devtools')devtools::install_github(c('alexvpickering/handlr', 'your_github_username/your_package'))
```