R Shiny/Restful Api 通信 [英] R Shiny/ Restful Api Communication

查看:57
本文介绍了R Shiny/Restful Api 通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个闪亮的应用程序,它采用 Json 中的输入文件通过分类器运行它并返回分类的 Json 对象.我希望应用程序能够与 API 进行通信.我希望 API 将文件发布到 Shiny 应用程序,该应用程序将完成其工作并返回一个分类对象.基本上,我希望 Shiny 应用程序处于后台,直到发布文件,然后执行其工作.我知道我可以使用 httr 包中的 GET 从 url 获取文件.我可以把它放在 Shiny.server 文件中,如果我知道 get 命令的文件名就可以了

I have a shiny app that takes an input file in Json Runs it through a classifier and returns a classified Json object. I want the app to be able to communicate with an API. I want the API to post a file to the Shiny App which will do its work and return a classified object. Basically I want the Shiny app to sit in the background until a file is posted and then do its work. I know that I can use GET from the httr package to get a file from a url. I can put this in the shiny.server file which is fine if I know the file name for the get command

但是来自 API 的文件名会有所不同.那么有什么方法可以根据来自 API 的 Post 请求使这个动态化.

However the filenames coming from the API will be different. So is there any way that I can make this dynamic according to the Post request that comes from the API.

推荐答案

如果你不必使用 Shiny,你可以使用 openCPU.OpenCPU 自动将您的每个 R 包作为 REST 服务提供.我使用 OpenCPU,它工作正常!这是从另一个程序中使用 R 的最简单方法.

If you do not have to use Shiny, you can use openCPU. OpenCPU provides each of your R packages as REST service automatically. I work with OpenCPU and it works fine! It is the easiest way to use R from another program.

这篇关于R Shiny/Restful Api 通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆