Change custom request & response commands by two kapow subcommands
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
#
|
||||
|
||||
kapow route add / - <<-'EOF'
|
||||
response /headers/Content-Type text/html
|
||||
response /body <<-HTML
|
||||
kapow set /response/headers/Content-Type text/html
|
||||
kapow set /response/body <<-HTML
|
||||
<html>
|
||||
<body>
|
||||
<a href='javascript: Array.from(document.querySelectorAll("a")).filter(x => x.href.indexOf("magnet") != -1 ).map(x => x.href = "http://localhost:8080/save/magnet?link="+encodeURI(x.href))'>Add me to your bookmarks!</a>
|
||||
@@ -28,16 +28,16 @@ kapow route add / - <<-'EOF'
|
||||
EOF
|
||||
|
||||
kapow route add /save/magnet -e '/bin/bash -c' - <<-'EOF'
|
||||
link=$(request /params/link)
|
||||
[ -z $link ] && response /status 400 && exit 0
|
||||
link=$(kapow get /request/params/link)
|
||||
[ -z $link ] && kapow set /response/status 400 && 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"
|
||||
|
||||
response /status 302
|
||||
response /headers/Location /torrent/list
|
||||
kapow set /response/status 302
|
||||
kapow set /response/headers/Location /torrent/list
|
||||
EOF
|
||||
|
||||
kapow route add /torrent/list -c 'response /body "Not Implemented Yet"'
|
||||
kapow route add /torrent/list -c 'kapow set /response/body "Not Implemented Yet"'
|
||||
|
||||
Reference in New Issue
Block a user