I would like to output the characters entered in the HTML form tag directly as an erb file without using a cgi file in between.
The server uses webrick, and there are only three file configurations: webrick configuration file, html file (value input), and erb file (value output).

Even if you enter characters in the form tag and send it, on the terminal
>(offline mode: enter name = value pairs on standard input)
Is displayed and i am asked to enter the parameters manually (if you enter them manually, the expected display will be displayed).
Corresponding source code
#webrick file for settings
config = {: DocumentRoot =>'./',
          : BindAddress =>'12',
          : CGIInterpreter =>'/Users/***/.rbenv/shims/ruby',
          : Port =>20080}
s = WEBrick :: HTTPServer.new (config)
s.config [: MimeTypes] ["erb"] = "text/html"
s.mount ('/ webrick_test.erb', WEBrick :: HTTPServlet :: ERBHandler,'webrick_test.erb')
trap ("INT") {s.shutdown}
<!-It's just html to fill in the form and send to the erb file->
<! DOCTYPE html>
  <meta charset = "UTF-8">
  <title>webrick test</title>
  <form action = "webrick_test.erb" method = "get">
      <input type = "text" name = "test">
      <input type = "submit">
<% require "cgi"%>
<% cgi = CGI.new%>
<% = cgi ["test"]%>
  • Answer # 1

    When I copied and pasted the file for webrick settings, erb did not work, so I added the following line and verified it.

    WEBrick :: HTTPServlet :: FileHandler.add_handler ("erb", WEBrick :: HTTPServlet :: ERBHandler)

    CGI isARGVIt seems to be in offline mode when is empty.
    How to avoid CGI offline mode

    SoCGI.newIn front ofARGVQuery string topushTo do.
    The query string isservlet_request.query_stringIt seems that you can get it at.

    <% require "cgi"%>
    <% ARGV.push (servlet_request.query_string)%>
    <% cgi = CGI.new%>
    <% = cgi ["test"]%>

    servlet_request.queryHowever, it seems that the parsed query string is stored, so
    I didn't have to use CGI just to output the query.

    <% = servlet_request.query ["test"]%>

    servlet_requestIs in erbbinding.prydo itlsI was able to find it at.