wisecow-httpserver

From NAT, 7 Years ago, written in Bash, viewed 624 times.
URL https://code.nat.moe/view/3ee3cb73 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2. SCRIPT="./wisecow-httpd"
  3. function http_200 {
  4.         echo "HTTP/1.0 200"
  5.         echo "Content-Type: text/plain"
  6.         echo "What: Fortune With Cowsay"
  7.         echo "Server: wisecow"
  8.         echo
  9. }
  10.  
  11. function http_server {
  12.         http_200
  13.         fortune | cowsay | sed -e "s/\n/<br>/g"
  14. }
  15.  
  16. function http_listener {
  17.         socat TCP-LISTEN:8010,fork,reuseaddr,crlf SYSTEM:"$SCRIPT http_server;"
  18. }
  19.  
  20. function main {
  21.         http_listener
  22. }
  23.  
  24. [[ -z $* ]] && main
  25. $*

Reply to "wisecow-httpserver"

Here you can reply to the paste above

captcha