Wednesday, June 23, 2010

Simple Webrick Server and shjs Syntax Highlighting

Since I've upgraded my machine, maruku hasn't been able to do syntax highlighting for me. I'm now giving shjs a shot. Here's a simple webserver using webrick.


# Get webrick
require 'webrick'
include WEBrick

# Create the server.
server = HTTPServer.new(:Port => 9090, :DocumentRoot => Dir::pwd)

# Shutdown if we get an interrupt.
trap("INT") { server.shutdown }

# Start the server
server.start


Not to much going on here. We get webrick included and create the server. The port here is 9090 (obviously you can pick any one that you want). The HTML files will be served from the current directory and this can be modified also. Then we shut down the server when we see a ^C and finally, we start the server.

I actually lifted this from somewhere and forgot to grab the link to give credit. If it's yours or you know who's it is, let me know so I can acknowledge them.

Let me know if you have questions.

No comments:

Post a Comment