This is a really simple question, but I cannot find any mention of this, anywhere..
How do I get the client's IP address from in Sinatra?
get '/' do "Your IP address is #{....}" end
Client IP addresses describe only the computer being used, not the user. If multiple users share the same computer, they will be indistinguishable. Many Internet service providers dynamically assign IP addresses to users when they log in.
Sinatra provides a request
object, which is the interface to the client request data that you should be using.
Using request.ip
is the preferred method to find the client's IP address:
get '/' do "Your IP address is #{request.ip}" end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With