Yes, yes, all these one-liner http server are great… but you're missing the point
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!
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.
Couldn't agree more - if all you need is a static file server, SimpleHTTPServer does the job. I made Knod specifically because I could not find a built in HTTP server that allows writing and deleting.
Got the idea while working through the React tutorial some time ago. Thought a zero config server that responds to all of the HTTP verbs would make a nice tool for front end prototyping.
I extended Python SimpleHTTPServer as a data store server for some web games and also as a cross-site XML server for said games. Knod would fit that niche just fine.
I am big fan of the mongoose server[0]. This python thing has issues handling concurrent requests, but i use it as a fallback, if mongoose is not installed.
I used SimpleHTTPServer for a while, but I found it a bit sluggish at times. I replaced SimpleHTTPServer with http-server, and I've been very pleased with its performance:
If you have twisted installed (which is the case on stock OSX), you can use the twisted webserver, which is a lot faster than SimpleHTTPServer and supports concurrent multiple downloads & resumes. I use this alias:
I don't think it was ever meant to be a server beyond a single user on a single machine. It's great for spinning up a server to start prototyping some web pages, etc. locally. Trying to serve content to multiple users (especially at the same time) is asking for trouble.
Which (coupled with SQLite) is what I use for all my PHP development stuff. No futzing around with Nginx or Apache configs, and a Phing or Makefile to run `make server` loading my particular dev setup (setting temporary ENV variables and the like) for the project is priceless. That feature is one of my favourites :)
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?
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.
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.
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.
Javascript was used for more specialized editing tools, like adding rows to certain tables and calculating totals (for example for [HTML5 invoices](http://www.jonathantneal.com/blog/the-html5-invoice/)). Remove DOM elements when you're done editing and PUT the page back.
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.
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.
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.
That's why I prefer it. A dev site with a bunch of resources could wedge the SimpleHTTPServer every couple of page loads. Still haven't overwhelmed http-server.
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!
I wonder what it does on GET /items though? Hopefully it concatenates all file contents into a JSON array