Получить IP-адрес клиента в Синатре?

Попробуйте это:

using System;
using System.Configuration;
using System.Web.Configuration;

namespace SampleApplication.WebConfig
{
    public partial class webConfigFile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Helps to open the Root level web.config file.
            Configuration webConfigApp = WebConfigurationManager.OpenWebConfiguration("~");
            //Modifying the AppKey from AppValue to AppValue1
            webConfigApp.AppSettings.Settings["ConnectionString"].Value = "ConnectionString";
            //Save the Modified settings of AppSettings.
            webConfigApp.Save();
        }
    }
}
37
задан dbr 23 August 2009 в 19:24
поделиться

1 ответ

Я все равно собирался опубликовать ответ ... итак:

get '/' do
"Your IP address is #{ @env['REMOTE_ADDR'] }"
end

Sinatra использует Rack :: Request API , поэтому вы можете использовать множество доступных в нем вещей.
Также ссылка на Sinatra документ .

17
ответ дан 27 November 2019 в 03:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: