Simple command line HTTP server

  • I have a script which generates a daily report which I want to serve to the so called general public. The problem is I don't want to add to my headaches maintance of a HTTP server (e.g. Apache) with all the configurations and security implications.

    Is there a dead simple solution for serving one small HTML page without the effort of configuring a full blown HTTP server?

    Why not just use netcat?

    Indeed! Use FTP, like the World Wide Web did before HTTP was finished! (Although I suppose it wasn't quite as world-wide in early 1990s. )

    A large collection of methods have been compiled in this gist

  • Alexander

    Alexander Correct answer

    9 years ago

    Yes, nweb.

    Can be found here: nweb.c

    (previously at ibm.com)

    To compile nweb.c:

    gcc -O -DLINUX nweb.c -o nweb
    

    It works well, but 2 comments for users: 1) it serves `index.html` from the provided directory, 2) from `nweb --help`: "Not Supported: URLs including "..", Java, Javascript, CGI". So, for example, Live.js to automatically refresh the page on file update does not work.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM