From: Brian Candler Date: 2012-12-14T06:07:13+09:00 Subject: Re: ruby on rails or sinatra for dynamic browser application Carlo E. Prelz wrote in post #1089024: > If I were you, I would not pull in rails for a simple thing - > especially if you do not plan to have many queries. Webrick (the > pure-ruby web server included in the Ruby source) works > very well. I would recommend Sinatra instead, because it sits on top of a number of webservers (including Webrick), making it more flexible, and it hides the low-level detail. However, start by writing a program which opens your file, iterates through the lines and writes it to stdout (i.e. forget about the web part). This should be easy enough if you're already using ruby. Then to convert it to sinatra, you just need to append your results to a string instead. require 'sinatra' get '/' do res = "" res << "\n" res << "\n" res << "
Hello
\n" res end If you want to continue using "puts" you can even use StringIO: require 'sinatra' require 'stringio' get '/' do r = StringIO.new r.puts "" r.puts "" r.puts "
Hello
" r.string end Then if you want to use a query string to control the output (e.g. to select which columns to sort by), look at the Sinatra docs for params. http://www.sinatrarb.com/intro -- Posted via http://www.ruby-forum.com/.