Cappuccino: A Really Simple Web-Server Powered By Restlet

| 1 TrackBack
Common problem: I need to share a bunch of files with a friend, or co-worker, but I can't send them via email because the files are greater than 10MB in total size.  I could send them to a local web-server, or post them on kolich.com, but that involves starting a new SSH session, some SCP's, what a mess.  I wish I had a really lightweight simple web-server that I can simply copy into any directory, and start with one command.  Once started, the web-server will simply serve files right from the directory I started it from (e.g., the web-server root becomes the current working directory).  Then I can tell my co-workers to visit http://192.168.1.100:8080, for example, to download the files.

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 Helpful?

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

  

Send Mark a Direct Message

If you'd like to send me a direct message, please do so below. However, I do not publicly post comments or messages submitted directly to me. So, if you're going to try to SPAM me, or my blog, you're pretty much wasting your time.

400 characters remaining

Error

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer, a casual entrepreneur, and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

1 TrackBack

I've been playing around with a lot of installer type stuff recently.  I discovered that Mozilla Firefox uses the 7zip SFX install launcher (if that's what you call it?) to kick off the Firefox installation process.  I started playing around... Read More

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on September 23, 2009 12:25 PM.

My Most Helpful and Least Helpful Blog Posts: June through September 2009 was the previous entry in this blog.

Apache: Setting the Content-Disposition Header with mod_rewrite is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.