我正在将一些 Python 代码转换为 Ruby,以便在 Rails 应用程序中使用。
Page1 将一些 JSON 数据发布到 Page2,然后 Page2 包含 Python 代码sys.stdin.readline()
以读取发布的 JSON 数据,然后对其进行处理。
我认为 Ruby 中的等价物是,gets.strip
但它导致我的服务器挂起。
原始 Python 代码:
import sys
data = sys.stdin.readline()
<manipulate contents of data>
有什么想法可能是错的吗?
更新
对于我的用例,request.raw_post
是适当的等价物。谢谢大家的回复。