Navigation
Project: CoreServer
13 April 2009
I tried to get Apache to run Ruby scripts like it would a PHP script. I know PHP, but it and Apache are huge. So, then I remembered Ruby's wonderful GServer class. It takes from TCPServer, which is as low as it gets: I had to write my own packet handlers for POST and GET requests.
Out of all of this came CoreServer, a 5.5kb (zipped) collection of 4 Ruby scripts, which work together to give me the two things I wanted:
- A working HTTP server
- Ruby web scripting
Currently, version 0.5.5 supports:
- Display of whole HTML pages
- Wrapping a template around HTML snippets
- Executing
.rb(Ruby) pages - Support for GET and POST variable types
- Conversely, support for HTML forms
- Easy extendability through Ruby code
- Aliasing pages to functions1
It's still being developed, but will work with just about any Ruby installation. Note that Windows users will need to follow this guide to fixing 0.5.5, since it uses a Linux command that you guys don't need.
Anyway, if this looks like your thing, it's worth a shot. By default, it opens a webserver at http://127.0.0.1/, so there's no threat of anybody outside your own computer (AKA you) accessing. You could probably run it on a LAN and whatnot, but I've yet to try
1 Basically, you alias a page name to a Ruby command. Say you want to show the server information, and you have a function that does that: serverInfo(). You simply set @alias["server_info"] = "serverInfo()". What that does: all requests to http://your.site/server_info don't make CoreServer get a file named "server_info"; instead, it executes the function you provided!
Comment eeeeeeeee