Again, JS server superstar Justin d’Archangelo wrote an implementation of a web server that works on Firefox OS. It’s called fxos-web-server and it includes a few examples you can run.
None of the examples particularly fit my use case–I want to serve static content from a phone to other phones, but the examples were a bit more contrived. So I decided to build a simpler proof-of-concept example: catserver, a web server that served a simple page with full screen Animated GIFs of cats:
Multicast DNS (or mDNS) lets you announce a service you’re offering in the network you’re connected to, and other devices can find (discover) it. For example, you could announce that your computer is running an FTP service. It’s the same thing that Apple does with its Bonjour protocol and that’s how you can find printers without knowing their IP address: they broadcast their existence, and your computer picks it up automatically for you.
Services have to be registered with a domain ending in .local. E.g. _ssh._tcp.local. The Wikipedia page has some background on why.
Now it also has a command line tool, and you can push and launch apps from the command line without even having to write a custom script that uses the module (of course, you can still use the module code by requiring it).
I’m doing some research and playing with this new-ish API which is available in Firefox OS on rooted phones with Certified apps etc etc. Guillaume wrote a post on the Hacks blog–read it if you’re interested in what can be accomplished.
The very first thing you need to do is to enable Wi-Fi direct on the device. This involves running some commands as root, via adb. Justin made a gist which worked with Flame phones, but it didn’t work with a Nexus 4, because of the way the /system partition is mounted on those phones.