有没有一种方法可以在没有参数的R中创建水管工API?
当用户ping ping时,我正在尝试仅返回一个字符串或数据框架。我正在使用水管工来创建此API。不幸的是,当我尝试执行此操作时,我会继续遇到404错误。这可以在水管工中吗?
library(plumber)
#* Test plumber of API with no parameters
#* @response default array with corresponding responses
#* @serializer unboxedJSON
#* @post /Test
function(){
return("Hello World!")
}
I'm trying to return just a string or a data frame as soon as the API is pinged by the user. I'm using plumber to create this API. Unfortunately, I keep on getting a 404 error when I try to do this. Is this possible in plumber?
library(plumber)
#* Test plumber of API with no parameters
#* @response default array with corresponding responses
#* @serializer unboxedJSON
#* @post /Test
function(){
return("Hello World!")
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它对我有用。将您的脚本保存为Plumber_test.r,然后打开R会话并输入
另一个终端尝试
,您应该返回
[“ Hello World!”]
It works for me. Save your script as plumber_test.R, then open an R session and type
In another terminal try
And you should get back
["Hello World!"]