Newer
Older
Loremap / otanisys / maruike.cgi
@otani otani on 3 Sep 2018 456 bytes cgi
#!/usr/bin/env ruby22
# -*- coding: utf-8 -*-

require 'cgi'
require 'json'
require 'sqlite3'
dbfile = 'db/maruike.sq3'

c = CGI.new({'accept_charset' => 'utf-8'})


print "Content-type: text/plain; charset=UTF-8\n\n"


tag = c['tag']


db = SQLite3::Database.new(dbfile)
db.busy_timeout = 1000

db.execute("CREATE TABLE IF NOT EXISTS name(tag text);")

db.execute("INSERT INTO name VALUES(?);", tag)
val = {'名前'=>tag}


puts JSON.pretty_generate(val)