diff --git a/examples/torrent.kapow b/examples/torrent.kapow new file mode 100644 index 0000000..519f335 --- /dev/null +++ b/examples/torrent.kapow @@ -0,0 +1,28 @@ +GET / { + echo "text/html" > @fifo:response/header/Content-Type + cat > @fifo:response/body <<-HTML + + + Add me to your bookmarks! + + +HTML +} + +GET /save/magnet { + set -x + link=@value:request/param/link + [ -z $link ] && echo 400 > @fifo:response/status && exit 0 + + watch_folder=/tmp + cd $watch_folder + [[ "$link" =~ xt=urn:btih:([^&/]+) ]] || exit; + echo "d10:magnet-uri${#link}:${link}e" > "meta-${BASH_REMATCH[1]}.torrent" + + echo 302 > @fifo:response/status + echo "/torrent/list" > @fifo:response/header/Location +} + +GET /torrent/list { + echo "..." > @fifo:response/body +}