Yes, yes, all these one-liner http server are great… but you're missing the point<p>Knod allows you to POST JSON data to a URL which it stores in a file so you can GET the same data back. If you're prototyping a one page JS app in, say, Ember this means that you don't need work on the backed logic, server or database. It's a pretty smart idea!<p>I wonder what it does on GET /items though? Hopefully it concatenates all file contents into a JSON array
While it doesn't support writing (POST/PUT etc), for serving files over HTTP from the current directory, Python's built in HTTP server is perfectly fine. It comes with Python 2.4+ as standard.<p><pre><code> python -m SimpleHTTPServer</code></pre>
So, you can only bind to '0.0.0.0'? Which means, by default, you're opening up read/write to the specified directory without permissions, to the entire world?<p>Maybe the default should be 127.0.0.1; and if the user specifies 0.0.0.0 then it comes with a big fat warning?
I have worked on a similar server off and on, but it was mostly for GET/PUT-ing HTML files (and not JSON data). That way you could put the contents of `document.documentElement.outerHTML` right back to where the page was retrieved from. The developer tools of the browser, as well as `contenteditable` can be used to create a relatively convenient HTML/content editor.<p>Additionally the pages were retrieved/saved from a local bare git repository and when some file was PUT it would be saved in a new commit and the branch would be updated. It allowed more collaboration, since multiple people could work on the same page without overwriting each others work.<p>Anonymous editing isn't yet implemented, but the idea is to have anyone being able to make changes (with some restrictions) and offer it to the site's owner (kind of like a pull request). It would allow wiki-like functionality for websites in general.<p>Javascript was used for more specialized editing tools, like adding rows to certain tables and calculating totals (for example for [HTML5 invoices](<a href="http://www.jonathantneal.com/blog/the-html5-invoice/)" rel="nofollow">http://www.jonathantneal.com/blog/the-html5-invoice/)</a>). Remove DOM elements when you're done editing and PUT the page back.<p>Recently I felt a bit constricted with this model, since some parts of the pages needed to be reused across multiple pages (like 'master pages' or blogpost entries). I've implemented a simple 2-way templating engine. Static pages can be built from the templates and from the page you could extract the templates, without losing data. That way you could edit the page as-is, but the parts that are templated are saved in the template (and reused in other pages). It did make the server more complex than a simple GET/PUT server, but the GET/PUT functionality was still preserved.<p>I see a lot of potential in such a GET/PUT server. With the right permissions for PUT operations, this can also be quite a decent 'CMS'-like server.
Ruby already has the ability to spin up a quick webserver for the current directory. This is supported through the un file in Ruby's stdlib: <a href="http://ruby-doc.org/stdlib-2.0.0/libdoc/un/rdoc/Object.html" rel="nofollow">http://ruby-doc.org/stdlib-2.0.0/libdoc/un/rdoc/Object.html</a>.<p><pre><code> ruby -run -e httpd -- --port=8080 .</code></pre>
Looks good.
I wrote something similar, a small gem called Ferver, no writes but you can point it to any directory then list or download files. Built on top of Sinatra.<p><a href="https://github.com/rob-murray/ferver" rel="nofollow">https://github.com/rob-murray/ferver</a>
Just chiming in with Node's http-server: <a href="https://www.npmjs.org/package/http-server" rel="nofollow">https://www.npmjs.org/package/http-server</a>
Why not use couchDB? It's marginally more work to deal with the _rev when updating a document, but you've then got a much more useful prototype.