Easiest way to have instant HTTP server

Sometimes you want to test some JavaScript/CSS on HTML page with some libraries you just downloaded. Opening *.html file in browser from a folder isn't always best solution - especially when scripts on page think it is HTTP protocol (not "file://" protocol). You can always try WAMP on Windows or native HTTP sharing on OSX, but it takes time. If you have only 5 seconds to start up a server - go to preferred folder in your terminal window and type this command:


python -m SimpleHTTPServer 8000

Just it! Go to your server http://localhost:8000.Works on Windows (with python installed), OSX and Linux.

Node.js simple server

For node.js fans: here is simple snippet for serving files

Install connect module (globally)
npm install -g connect
Save snippet as server.js file and run:
node server.js

0 komentarze: