Over the weekend I required a very simple web server on my MacBook to allow me to play around with some iPhone Web App development. It didn’t need to do much, simply accept requests and serve webpages. While I’ve created web servers before, after sending a tweet out I was reminded about Mono XSP. XSP is an ASP.net web server developed under the Mono project banner allowing you to serve web pages and asserts (javascript, css, images etc) to clients. Simply – it’s great!
After installing Mono, to launch a server simply navigate to the directory where your pages resides using a Terminal (command prompt), and type in XSP. This will start a full webserver on port 8080 serving pages from the directory. Now, within seconds, I can quickly make any directory on my laptop accessible over HTTP!
On OSX, the execution simply looks like this:
Pretty:Base Ben$ xsp
xsp2
Listening on address: 0.0.0.0
Root directory: /Users/Ben/SourceControl/iPhoneWebApp101/iWebKit/Base
Listening on port: 8080 (non-secure)
Hit Return to stop the server.
Great for prototyping and rapid development and while I haven’t tried it, it should work on Windows equally as well.