mypod.me

iPhone hackery and networkery with chewy BSD goodness!

rainbow

Posts Tagged ‘ubiquitous computing’

iServe

Let me explain why you really do need a web server on your iPhone.

When I mentioned this on Twitter and thereabouts, a few days ago, I was greeted with incredulity. After all, the web is big and wide – why would you also need a web server that you can carry around in your pocket?

The answer is simple, and so very obvious that I’m now shocked Apple didn’t think of this themselves.

Let me present my latest invention: iServe.

iServe leverages the ubiquitous technology of the World Wide Web with the fast-becoming-ubiquitous technology of ZeroConf (known as Bonjour in the Apple universe). When you put these two technologies together into a jailbroken iPod Touch or iPhone, you get a portable and fully scalable document viewing platform. Let me explain…

I have been using my iPhone to read PDF files – specifically, I’ve been reading Apple’s Safari Web Content Guide for iPhone OS. It’s useful – and came in handy for iServe – but it’s a book-style PDF file, which means that the pages are too big to be comfortably read on the iPhone’s screen. Silly for Apple to make a mistake like this, but they’re still thinking of a “book” as something that’s printed on 8 1/2 x 11″ or A4 size pages. It isn’t, not really, but PDF format (or rather, the viewers for PDF format) don’t take this into account. So, I read the Apple PDF in landscape mode on my iPhone, but, even with the 480 pixel-width screen, I had to constantly swipe a finger across the screen to see the end of the line I was reading. Not at all pleasant. (Yes, I could shrink the document to fit across the display, but I can not read 4-point font sizes. Reading should not be an optometric exam.)

iServe provides an elegant solution to this problem. Using the lighttpd web server I installed this morning, which has a document root at /var/www, I created a new subdirectory, /var/www/iserve. Into this directory I place whatever PDF, DOC and XLS files I might want to view. I then wrote a Python script, index.py, placed into this directory, so it is executed whenever a request for the iserve directory contents is received. This script simply reads the contents of the directory and gives a nicely-formatted HTML output in response. This script either works directly from Mobile Safari on the iPhone (where it’s accessed at http://localhost/iserve/), or, because of Bonjour services which are always running on the iPhone, it can be accessed at http://lugh.local/iserve/ from any machine residing on the same physical network as my iPhone. And that’s the magic of it: if I want to read a PDF on my iPhone, I can do it, using Mobile Safari as a launchpad. If I want to read it from, say, my MacBook Pro, I can do that too, using Safari (or Firefox) as a launchpad.

Suddenly I have a scaleable, ubiquitous display capability for any of the documents on my iPhone.

A few pictures might help. Here’s the icon for iServe on my iPhone:

iServe icon

When I tap on that icon, I launch Mobile Safari, and this is what I see:

iServe

I can scroll through and tap on any of these documents, launching the appropriate viewer.

Now, if I should wander into my flat, I can walk up to my MacBookPro, and do precisely the same thing:

iServe Desktop

Voila. Portability and scalability. This is more than a convenience. I could perhaps be carrying documents to a client for review. I can review them on the train as I travel to the meeting, then, when I arrive in the client’s offices, I can simply present my iPhone, connect to the client’s network, and browse the documents. The client can do a “Save As…” command on their browser, should they want their own copy of these documents.

It’s all very simple, and very elegant. And it makes me very confused that Apple overlooked this. Now perhaps some enterprising entrepreneur is putting together something in the App Store which does this. In some sense, FileMagnet (an iPhone app which I own) does this. But it’s entirely proprietary and requires a client program to be installed on a Mac or PC. Using standard web technologies makes this much easier. Web browsers are everywhere. Wireless networks are everywhere. Shouldn’t an iPhone or iPod Touch put those ubiquitous resources to work?