Forums

Running R Shiny

Hi,

Is it possible to run R Shiny web apps (http://shiny.rstudio.com/) in pythonanywhere.com? It would be extremely nice to integrate Shiny and web2py since Shiny has great reactive programming capabilities.

I don't think so, it looks like it needs to run as its own (non-Python) web server :-(

Thanks for the answer!

But I think it should still be possible to use Shiny apps with runApp() command (http://shiny.rstudio.com/reference/shiny/latest/runApp.html) - so that when user goes to a page, the app is executed first and then user is redirected to the app. I tried to get it working by installing shiny package from R command line, then copied files ui.R and server.R needed for the Shiny app to the folder /home/katsetus/shiny/ and then run the following line from pythonanywhere bash:

Rscript -e 'library(methods); shiny::runApp("/home/katsetus/shiny/", port = 7705)'

Now, it says Shiny is listening on http://127.0.0.1:7705 - which is the normal way how Shiny also works on my local computer, except that in the interactive mode, a browser tab is opened automatically. My problem is now, how can I redirect my web2py app to show contents of the Shiny app? Or should I use some other address instead of the default 127.0.0.1?

Thanks for any help!

Best, Tauno

That's the problem -- the console servers on PythonAnywhere aren't externally visible, so there's no way you can point a web browser at them. Our plan is to fix that so that you can run any web server inside PythonAnywhere and we'll handle the routing to it, but that's not implemented yet.

OK, thanks for the explanation!

Looking forward for the developments :).

Best, Tauno

We'll let you know when it's done -- no timeline yet, though :-(

Has this been implemented? Thanks

You wouldn't be able to run shiny as a webapp unless it can be run as a uWSGI application.

However, I see that there seems to be a 3rd party shiny in the cloud service that they are offering. (so maybe you could use that + pythonanywhere?)

Shinyapps.io is terrible if you want to host multiple apps. Will Shiny apps be supported in the future?

Never saw R Shiny before, but I wonder if the Python ecosystem has something similar. Spyre, perhaps? If it has various widgets, it seems easier to integrate a Python project into your Python app. I'm going to have to work on that.

Edit: maybe plotly dash is analogous?

It's possible we'll be able to support Shiny, yes. Right now we only support WSGI-based Python web apps. However, our current development is aiming to support any kind of HTTP-based server. There are a couple of steps along the way before we can get there, and it's likely to only work for paid accounts when it does land, but in the medium term I think we'll get there. No timelines yet, though!

plot.ly/dash seems to be the answer. I see a lot of activity in the visualization community, on both sides of the R/Python bridge. Hate the language but love their plots? Python can call JavaScript libraries (folium for Leaflet.js, bokeh implements D3.js, etc). For my latest client, whose website is now hosted on Pythonanywhere, I ended up calling Shiny to create the graphs... from another server. Plot.ly, I think, does precisely that, offer visualization as a service (but for a cost if I understand well).

I tried nvd3 (Python library that generates some of the most common d3 charts) and it was pretty good and easy to use (just like Python is 10x easier to use than JS haha). But that's not building a mini-app with NO knowledge of html, css, js. That is a pretty cool concept and I'm not sure if plot.ly really is the exact same?

Checking in -- has this been implemented? Thanks!

No, we're still WSGI-only right now.