A Bash web server

One Liners

© Lead Image © valenty, 123RF.com

© Lead Image © valenty, 123RF.com

Author(s):

With one line of Bash code, you can create a Bash web server for quickly viewing the output from Bash scripts and commands.

For people who do a lot of work with command-line tools or Bash code, having a Bash web server could be very handy. I was really amazed that in one line of Bash code I was able to create web servers that could:

  • Send the output from a Bash command directly to a browser page
  • Create diagnostic pages using standard Linux tools
  • Create pages that view Raspberry PI GPIO pins
  • Create a page to toggle a Rasp PI GPIO pin

One-Line Web Servers

While a number of minimal, one-line web servers exist in most programming languages [1], you can create a Bash web server using the networking utility nc (or netcat) as follows:

[...]