9 ms·
Knod – A Tiny HTTP server for your current directory with writes
- jamescun 12y agoWhile 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. python -m SimpleHTTPServer
- TinyBig 12y agoCouldn'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.
- rafekett 12y agoI'm curious -- what is your use case is for writing and deleting?
- samstave 12y ago"Hey bob, here is a link to a folder on my machine - can you upload that those [random file types] you want me to look at?" or "non-tech wife needs to get this file to our home machine, she can use my link to /home/put/ to send this to my home machine from her work"
- michaelmior 12y agoHow is a non-technical person supposed to execute a POST request with an attached file to Knod?
- jacquesm 12y agoAt a guess, using a browser with a file upload form downloaded from the same place where the file will go.
- michaelmior 12y agoThat's fair, although it goes beyond what Knowd provides.
- TinyBig 12y agoGot 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.
- failrate 12y agoI 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.
- tdicola 12y agoAnd for the python3 folks: python3 -m http.server
- deleted 12y ago[deleted]
- Joeri 12y agoSame thing for php 5.4+: php -S localhost:8000
- girvo 12y agoWhich (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 :)
- el_benhameen 12y agoI 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: https://github.com/nodeapps/http-server https://github.com/nodeapps/http-server Not standard (or Python), but it's a quick install, and I find it just as usable and much faster.
- woadwarrior01 12y agoIf 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: alias twisted_web='twistd -n web --path $PWD'
- pekk 12y agoI wish this weren't true, but it's a terrible server - all but unusable. Just try to serve requests to several hosts within the same few seconds.
- tdicola 12y agoI 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.
- mixmastamyk 12y agopip install waitress Is a good choice when you need a little more oomph but not nginx.
- ushi 12y agoI 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. [0] https://github.com/cesanta/mongoose https://github.com/cesanta/mongoose
- Hello71 12y agoor, even better (and supported almost everywhere): busybox httpd -p 8080 I have not yet found any boxen having ruby but not busybox httpd.
- acdha 12y ago> I have not yet found any boxen having ruby but not busybox httpd. Other than OS X?
- drhayes9 12y agoJust chiming in with Node's http-server: https://www.npmjs.org/package/http-server https://www.npmjs.org/package/http-server
- semiquaver 12y agoYou can do this in ruby using: ruby -run -e httpd . -p 5000
- TinyBig 12y agoIt's an HTTP server that allows reading and writing, hence it is different than the static file servers built into many languages.
- jtdowney 12y agoRuby 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: http://ruby-doc.org/stdlib-2.0.0/libdoc/un/rdoc/Object.html http://ruby-doc.org/stdlib-2.0.0/libdoc/un/rdoc/Object.html. ruby -run -e httpd -- --port=8080 .
- marcosnils 12y agoSay no more!.
- avidal 12y agoSo, 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?
- ___rob_m 12y agoLooks 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. https://github.com/rob-murray/ferver https://github.com/rob-murray/ferver
- hopeless 12y agoYes, 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
- ImJasonH 12y agoYeah, a fake "sticky" backend can be really useful in prototyping a frontend. I built a similar thing to help with that, built on App Engine (which I usually just run locally): https://github.com/ImJasonH/simply-put https://github.com/ImJasonH/simply-put It supports GET/POST/DELETE and simple queries. I ended up having more fun writing the devel backend than whatever it was I was writing :)
- TinyBig 12y agoConcatenating the contents into a JSON array is an excellent idea! I'll get to work on that.
- bruce_one 12y agoNot quite the same, but [Interfake](https://github.com/basicallydan/interfake https://github.com/basicallydan/interfake) is a pretty cool tool for creating mock APIs :-) Would be even better with a way to do something like this though :-)
- rbosinger 12y agoI get this: `<class:Server>': undefined method `using' for Knod::Server:Class (NoMethodError) Am I a loser?
- TinyBig 12y agoIt requires Ruby 2.1
- davidbanham 12y agoWhy 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.
- nl 12y agoBecause then you need another webserver for the static files.
- davidbanham 12y agoWhy 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.
- FrozenCow 12y agoI 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/) 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.