A Simple Bash HTTP Server

From NAT, 7 Years ago, written in Plain Text, viewed 597 times.
URL https://code.nat.moe/view/eb3940f3 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2. SCRIPT="./hello"
  3. function http_200 {
  4.         echo "HTTP/1.0 200"
  5.         echo "Content-Type: text/plain"
  6.         echo
  7. }
  8.  
  9. function http_server {
  10.         http_200
  11.         echo "It's Works!"
  12. }
  13.  
  14. function http_listener {
  15.         socat TCP-LISTEN:8010,fork,reuseaddr,crlf SYSTEM:"$SCRIPT http_server;"
  16. }
  17.  
  18. function main {
  19.         http_listener
  20. }
  21.  
  22. [[ -z $* ]] && main
  23. $*

Reply to "A Simple Bash HTTP Server"

Here you can reply to the paste above

captcha