A few weeks ago, I went through a Restlet tutorial for a project at work, and knew that Restlet supported its own internal HTTP web-server for serving up static files. I wanted to learn a little more about this, so I created Cappuccino. Cappuccino is a lightweight server that uses Restlet's internal HTTP web-server to serve up static files from the directory it's started from. Technically speaking, Cappuccino is just a handsome wrapper of Restlet's internal HTTP server.
Using Simon Tuff's one-jar, I packaged all required libraries and resources into a single .jar file. As a result, you can start Cappuccino with a one-liner (assuming you have a good JRE installed in your path):
#/> java -jar cappuccino.jar
Once started, Cappuccino serves up static files in the current directory on port 8080 by default. Of course, you can change the default port:
#/> java -jar cappuccino.jar 8099
You can also add an alias to your *NIX shell (bash, etc.) for automatic downloading and start up of Cappuccino from the current working directory. For example, set a "servehere" alias to automatically download the latest Cappuccino and run it:
#/> alias servehere='lynx -dump http://kolich.cc/cino > cappuccino.jar; \
java -jar cappuccino.jar'
Once set, simply type servehere to download and start Cappuccino from the current directory.
Note: I tried using "wget --quiet http://kolich.cc/cino" to automatically download cappuccino.jar in the alias example above, but it appears that wget doesn't always obey the Content-Disposition header sent by my web-server. It seems that wget on my CentOS box understands the Content-Disposition header by default, but wget on my Fedora 7 box does not. Better to use Lynx, which gets it right more often than not.
Download the Source:
http://mark.koli.ch/cappuccino/src/cappuccino-v0.1.zip
Download the Runnable Jar:
http://mark.koli.ch/cappuccino/dist/cappuccino-v0.1.jar
Enjoy.


Did you find this post helpful, or at least, interesting?