12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | #!/bin/sh
case "$METHOD" in
GET)
body="$(cat <<-EOF
<!DOCTYPE html>
<html>
<body>
<h1>GET</h1>
<pre>
GET params:
x=$GET_x
y=$GET_y
</pre>
<form action='/params' method='POST'>
Foo: <input type="text" name="foo">
Baz: <textarea name="baz"></textarea>
<input type="submit" value="submit">
</form>
</body>
</html>
EOF
)"
;;
POST)
body="$(cat <<-EOF
<!DOCTYPE html>
<html>
<body>
<h1>POST</h1>
<pre>
GET params:
x=$GET_x
y=$GET_y
POST foo:
$POST_foo
POST baz:
$POST_baz
</pre>
<a href='javascript:window.history.back()'>Back</a>
</body>
</html>
EOF
)"
;;
*)
http-msg <./404.html 'HTTP/1.1 404 Not Found'
exit 1
;;
esac
cat <<-EOF
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: ${#body}
$body
EOF
# vim: ts=2:noexpandtab
|