LoginSignup
1
1

More than 5 years have passed since last update.

ユーザーエージェント調べる

Posted at

WindowsPhoneのアプリでChromiumが出たんですけど、これって一体UserAgentは何かと気になりました。

ということで、さっと作ってみました。

準備

Rubyとbundleは既にインストール済の前提です。

Gemfile
source :rubygems
gem 'sinatra'
gem 'slim'
$ bundle install

本体

check_agent.rb
require 'sinatra'
require 'slim'

get '/' do
    @ua = request.user_agent
    slim :index
end
views/index.slim
doctype html
html
  head
    title UserAgentCheck

  body
    h1 User Agent Checker
    = @ua

では実行。

$ bundle exec ruby check_agent.rb

モバイル機器とかから「http:// PCのIPアドレス:4567/」にアクセスすると、Agent情報が表示されます。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1