Skip to content

Instantly share code, notes, and snippets.

View tropicloud-2k's full-sized avatar

Tropicloud tropicloud-2k

View GitHub Profile
@tropicloud-2k
tropicloud-2k / http.sh
Last active August 29, 2015 14:25
Netcat HTTP server (/bin/bash http.sh 9000)
#!/bin/bash
# https://gist.github.com/marcellodesales/9e4288f35ac2cc3e1b83
PORT="$1"
OUTPUT="/tmp/stdout"
rm -f $OUTPUT
mkfifo $OUTPUT
trap "rm -f $OUTPUT" EXIT
echo "Starting HTTP server"
@marcellodesales
marcellodesales / formatted.sh
Last active November 14, 2023 19:22
One-liner REST server using netcat - nc
rm -f out
mkfifo out
trap "rm -f out" EXIT
while true
do
cat out | nc -w1 -l 1500 > >( # parse the netcat output, to build the answer redirected to the pipe "out".
export REQUEST=
while read line
do
line=$(echo "$line" | tr -d '[\r\n]')