Skip to content

Instantly share code, notes, and snippets.

View kevn-xyz's full-sized avatar

Kevin kevn-xyz

View GitHub Profile
@kevn-xyz
kevn-xyz / ncws
Last active February 12, 2024 19:40
Simple netcat based one shot http file server
#!/bin/bash
file=$1
port=$2
if [[ -n "$file" ]] && [[ -n "$port" ]]; then
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Disposition: inline; filename=\"$1\"\r\nContent-Length: $(wc -c < $file)\r\n\r\n"; cat $file; } | nc -l $port
else
echo "Usage: ncws <file> <port>"
fi