本文介绍了在Sinatra中获取客户的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个非常简单的问题,但我在任何地方都找不到任何提及..
This is a really simple question, but I cannot find any mention of this, anywhere..
如何从Sinatra中获取客户的IP地址?
How do I get the client's IP address from in Sinatra?
get '/' do
"Your IP address is #{....}"
end
推荐答案
Sinatra提供了 request
对象,它是您应使用的客户端请求数据的接口.
Sinatra provides a request
object, which is the interface to the client request data that you should be using.
使用request.ip
是查找客户端IP地址的首选方法:
Using request.ip
is the preferred method to find the client's IP address:
get '/' do
"Your IP address is #{request.ip}"
end
这篇关于在Sinatra中获取客户的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!