#!/usr/bin/ruby

require "cgi"
input = CGI.new

print "Content-type: text/html\n\n";

new = CGI.escapeHTML(input["str"])

if new != "" then
  fp=open("li_list","a")
  fp.puts(new)
  fp.close
end


def foodlist
  fp=open("li_list")
  list=""
  while w = fp.gets
    ww=CGI.escapeHTML(w.chomp)
    list=list+"<li>"+ww+"</li>\n"
  end
  fp.close
  list
end

html=foodlist()


print <<-AA
<html>
<head>
<title>fuga</title>
</head>
<body>
<h1>GoGoRuby</h1>
<p>hello:</p>
<hr />
<p>you send :[#{new}]</p>
<hr />
<ul>
#{html}
</ul>

<hr />
<form  method="post" action="" >
<input type="text" name="str"/>
<input type="submit" value="push" />
</form>

</body></html>
 AA

