root/lang/ruby/ssb/public_html/ktai_db.rbx @ 2145

Revision 2145, 1.0 kB (checked in by coji, 6 years ago)

lang/ruby/ssb: ケータイDBからの検索でuseragentからの部分一致サポートを追加

  • Property svn:mime-type set to text/x-ruby; charset=utf-8
  • Property svn:eol-style set to native
  • Property svn:executable set to on
  • Property svn:keywords set to
    Id Date Author Rev URL
Line 
1#!/usr/bin/env ruby
2# -*- ruby -*-
3#
4# Author:: MIZOGUCHI Coji <mizoguchi.coji at gmail.com>
5# License:: Distributes under the same terms as Ruby
6#
7# $Id$
8#
9require '../config/common.rb'
10require 'webrick/cgi'
11require 'ssb/ktai_db'
12
13module SSB
14  class KtaiDBHandler < WEBrick::CGI
15    def initialize
16      super
17      @db = ::SSB::KtaiDB.new(true)
18    end
19
20    def do_GET(req, res)
21      res.header['Content-Type'] = 'text/html; charset=utf-8'
22      ktai = @db.search(:carrier   => req.query['carrier'],
23                        :name      => req.query['name'],
24                        :useragent => req.query['useragent'])
25      res.body += "<h1>search result</h1>"
26      res.body += "carrier: #{req.query['carrier']}<br />"
27      res.body += "name: #{req.query['name']}<br />"
28      res.body += "useragent #{req.query['useragent']}<br />"
29      res.body += "result: #{ktai.size}"
30      res.body += "<hr />"
31      ktai.each do |k|
32        res.body += "#{k[:name]}<br />\n"
33      end
34    end
35  end
36end
37
38SSB::KtaiDBHandler.new.start()
Note: See TracBrowser for help on using the browser.