Is it possible to use Ruby as a scripting language with a HTTP server ? I’d like to be able to simply put some Ruby files in a web directory and be able to execute them from my browser – just like I did with PHP.
I have absolutely nothing against frameworks such as RoR, but I was told that I should first learn Ruby and only then move on with higher level frameworks. Of course, I could write some Ruby scripts and run them in the console, but I would prefer getting the input/output from my browser 🙂
Is that possible at all ? Otherwise, how hard would it be for me to build a quick and simple web framework ?
Depends on your server, but any language can be used with CGI Programming, including Ruby.
Generally speaking – to find out – put a basic “Hello World”
.rbor.cgifile on your web server andchmodit’s permissions so it is executable to “others”:When writing CGI scripts, you have to ensure that you have the appropriate shebang at the top of your file. For Ruby you’d probably use something like…
(no promises this is the one)
Then write yourself a little hello world CGI script. The output of a CGI script is kind of a partial HTTP Response: (I’m not really a Ruby coder so this might be completely arse-backwards)
Visit the file the same way you would a PHP or Perl script and you’ll see if it works. Again; it depends on your server.