Skip to content

Instantly share code, notes, and snippets.

@bencord0
Last active August 12, 2024 20:35
Show Gist options
  • Save bencord0/4815bae08e470ff31ce3020032acc7fe to your computer and use it in GitHub Desktop.
Save bencord0/4815bae08e470ff31ce3020032acc7fe to your computer and use it in GitHub Desktop.
HTTP server in bash, using examples/loadables/accept.c (from the bash source code)
#!/bin/bash
enable accept
accept 1234
while read -u $ACCEPT_FD -t 1 line; do
echo "$line"
done
echo "HTTP/1.1 200 OK" >&$ACCEPT_FD
echo "Content-Type: text/plain" >&$ACCEPT_FD
echo "Connection: close" >&$ACCEPT_FD
echo >&$ACCEPT_FD
echo "Hello, world!" >&$ACCEPT_FD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment