cgi header processing
[platform/upstream/libwebsockets.git] / test-server / lws-cgi-test.sh
1 #!/bin/sh
2
3 echo -e -n "Content-type: text/html\x0d\x0a"
4 echo -e -n "\x0d\x0a"
5
6 echo "<html><body>"
7 echo "<h1>lwstest script stdout</h1>"
8 >&2 echo "lwstest script stderr"
9
10 echo "<h2>REQUEST_METHOD=$REQUEST_METHOD</h2>"
11
12 if [ "$REQUEST_METHOD" = "POST" ] ; then
13         read line
14         echo "read=\"$line\""
15 else
16         echo "<table>"
17         echo "<tr><td colspan=\"2\" style=\"font-size:120%;text-align:center\">/proc/meminfo</td></tr>"
18         cat /proc/meminfo | while read line ; do
19                 A=`echo "$line" | cut -d: -f1`
20                 B=`echo "$line" | tr -s ' ' | cut -d' ' -f2-`
21                 echo -e "<tr><td style=\"background-color:#f0e8c0\">$A</td>"
22                 echo -e "<td style=\"text-align:right\">$B</td></tr>"
23         done
24         echo "</table>"
25 fi
26
27 echo "<br/>done"
28 echo "</body></html>"
29
30 exit 0
31