From: Justin White Date: 2002-12-14T12:22:28+09:00 Subject: Re: Can an .rbx file send it's own code? On Friday, December 13, 2002, at 12:27 , Chris Pine wrote: > Hello, > > I was wondering if there's a way to make a web page (generated in Ruby) > with > a link which, when clicked, would send itself... not the generated > page, but > the actual page-generating Ruby program, the whole .rbx file. > > I can't figure out any easy way to do this... any thoughts? > > Chris i put this simple test at the front of the main body of the script: -- cgi = CGI.new ## or whatever CGI library you use if cgi.has_key? 'source' out = Array.new out << "Content-type: text/plain\n\n" File.open $0, 'r' do |file| out << file.read end puts out exit end -- when i want to show the source, simply load the page with 'source' as the cgi argument: http://tin.2y.net/scripts/bookmarker.rb?source create a link with 'source' in the normally generated page -Justin