7.2 Sharing as a webpage
7.2.1 For temporary uses
Say I have a Shiny app on my desktop in my office and I’ll have a meeting in a conference room somewhere in my department. It might be a good choice to host the Shiny app temporarily on my desktop.
- Find out your IP address. To access your app from other computer, you need to know your IP address. For Windows system, use
ipconfig
command in Command Prompt (Win
+ R, then inputcmd
and Enter) . In linux, useifcondig
instead. Remember your IP4 Address, for example, mine is10.26.52.173
as shown in Figure 7.1.
- Run the following command on the machine hosting the Shiny app.
runApp(host = "0.0.0.0", port = 80)
The default value of host
is 127.0.0.1
(localhost) which means that only the current machine can access it. To allow other clients to connect, host
need to be set to 0.0.0.0
.
- Now you can access the Shiny app by typing the IP address in your browser from other machines.
My IP address starts from 10
, which means it is a private IP, so only people using the same private network as me can access it. Private IP usually have the following ranges:
192.168.0.0 - 192.168.255.255 (65,536 IP addresses)
172.16.0.0 - 172.31.255.255 (1,048,576 IP addresses)
10.0.0.0 - 10.255.255.255 (16,777,216 IP addresses)
If your IP is not a private IP, anybody using the Internet may have access to your Shiny app. You may consult the IT department of your organization for details.
7.2.2 For long term uses
Using shinyapps.io, the Rstudio’s hosting service for Shiny apps.
- Building your own Shiny Server.
- Need a linux server
Open source edition (free) and Pro edition (advanced features)