├── cgi-bin ├── test └── httputils └── README.md /cgi-bin/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Example Bash CGI script. 4 | # 5 | # Caveat: Remember the empty line after echoing headers 6 | # 7 | 8 | # httputils creates the associative arrays POST_PARAMS and GET_PARAMS 9 | if [[ "$SCRIPT_FILENAME" ]]; then 10 | . "$(dirname $SCRIPT_FILENAME)/httputils" 11 | else 12 | . "$(dirname $(pwd)$SCRIPT_NAME)/httputils" 13 | fi 14 | 15 | POST_vars_to_str() { 16 | local __resultvar=$1 17 | local q 18 | for param in "${!POST_PARAMS[@]}"; do 19 | q="${q} \"${param}\": \"${POST_PARAMS[$param]}\"," 20 | done 21 | eval $__resultvar="'$q'" 22 | } 23 | 24 | do_POST() { 25 | POST_vars_to_str result 26 | echo "Status: 200 OK" 27 | echo "" 28 | cat <