wok-stable view busybox/stuff/www/cgi-bin/index.cgi @ rev 10898

busybox/httpd: add directory index
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jul 15 11:34:28 2011 +0200 (2011-07-15)
parents
children 491decbaa244
line source
1 #!/bin/sh
3 [ ! -d ..$QUERY_STRING ] && echo "HTTP/1.1 404 Not Found" || cat <<EOT
4 Content-type: text/html
6 <!DOCTYPE html>
7 <html xmlns="http://www.w3.org/1999/xhtml">
8 <head> <title>Index of $QUERY_STRING</title> </head>
9 <body>
10 <h1>Index of $QUERY_STRING</h1>
11 <ul>
12 $({ [ "$QUERY_STRING" != "/" ] && echo "../"; ls -p ..$QUERY_STRING; } | \
13 sed 's|.*| <li><a href="&">&</a></li>|')
14 </ul>
15 </body>
16 </html>
17 EOT