Saturday, December 19, 2015

Serving local files with a simple http file server built on NodeJS

Sometimes we want to share some files in a local network or we want to host quick local app demos for others to play with or we are forced to have files served by http to test tooling like it was my case this time.

I was playing with Git Patch Viewer chrome extension to see how specific patch files were shown but the extension wouldn't parse local file:// referenced resources.

I have published the most simple http file server I could build to address this issue. Probably you can share a better/shorter way?

2 comments:

Corey Goldberg said...

it's a one-liner in Python:
$ python -m SimpleHTTPServer

Nestor Urquiza said...

Thanks for sharing Corey. In node you do have a one liner to produce the exact same result "http-server". However it will not handle specific directories neither serving specific mime types. For that you will need extra coding in python or node.

In addition the server I published contains icons and search as well. I am sure you will need 26 lines or more to get a similar product in python, correct? Cheers, - Nestor

Followers