parent
8b1d977e19
commit
4ae2e9718b
Binary file not shown.
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set -x
|
||||
|
||||
if [ "$1" != '-server' ]; then
|
||||
socat TCP-LISTEN:2000,fork,reuseaddr EXEC:"$0 -server"; exit $?
|
||||
fi
|
||||
|
||||
case $@ in
|
||||
'-server')
|
||||
read request
|
||||
method=$(echo $request | cut -d " " -f 1)
|
||||
fich=$(echo $request | cut -d " " -f 2)
|
||||
if [ $fich = "/" ]; then
|
||||
fich="/index.html"
|
||||
fi
|
||||
|
||||
fich="./www-test/${fich:1}"
|
||||
|
||||
|
||||
if [ $method != 'GET' ]; then
|
||||
echo -e -n "HTTP/1.1 403 Forbiden\r\n"
|
||||
echo -e -n "Content-Length: 14 \r\n"
|
||||
echo -e -n "Connection: close\r\n"
|
||||
echo -e -n "Content-Type: text/plain\r\n"
|
||||
echo -e -n "\r\n"
|
||||
echo -e -n "403 : Forbiden\n";echo -n "Erreur 403" >&2;exit $?
|
||||
|
||||
fi
|
||||
if [ ! -f $fich ]; then
|
||||
echo -e -n "HTTP/1.1 404 Not found\r\n"
|
||||
echo -e -n "Server: Apache/2.2.22 (Debian)\r\n"
|
||||
echo -e -n "Accept-Ranges: bytes\r\n"
|
||||
echo -e -n "Content-Length: 15\r\n"
|
||||
echo -e -n "Content-Type: $mine\r\n"
|
||||
echo -e -n "Connection: close\r\n"
|
||||
echo -e -n "\r\n"
|
||||
echo -n "404 : Not Found";echo "Erreur 404" >&2
|
||||
fi
|
||||
|
||||
mime=$(file -L --brief --mime-type $fich)
|
||||
|
||||
echo -e -n "HTTP/1.1 200 OK\r\n"
|
||||
echo -e -n "Server: Apache/2.2.22 (Debian)\r\n"
|
||||
echo -e -n "Accept-Ranges:bytes\r\n"
|
||||
echo -e -n "Content-Length: $(cat $fich | wc -c)\r\n"
|
||||
echo -e -n "Content-Type: $mine\r\n"
|
||||
echo -e -n "Connection: close\r\n"
|
||||
echo -e -n "\r\n"
|
||||
|
||||
cat $fich
|
||||
|
||||
;;
|
||||
esac
|
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 302 KiB |
@ -0,0 +1 @@
|
||||
test.html
|
@ -0,0 +1,36 @@
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
body {
|
||||
background-color: white;
|
||||
font-family: Verdana, sans-serif;
|
||||
font-size: 100%;
|
||||
}
|
||||
h1 {
|
||||
font-size: 200%;
|
||||
color: navy;
|
||||
text-align: center;
|
||||
}
|
||||
h2 {
|
||||
font-size: 150%;
|
||||
color: red;
|
||||
padding-left: 15px;
|
||||
}
|
||||
p,ul,li,td {
|
||||
color: black;
|
||||
}
|
||||
a:link {
|
||||
color: green;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:visited {
|
||||
color: gray;
|
||||
}
|
||||
a:hover {
|
||||
color: red;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:active, a:focus {
|
||||
color: red;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>test-img-css.html </title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<center><h1>Page de test simple + image + css</h1></center>
|
||||
<ul>
|
||||
<li><a href="test.html">Page de test simple</a></li>
|
||||
<li><a href="test-img.html">Page de test avec une image</a></li>
|
||||
<li><a href="test-img-css.html">Page de test avec CSS et image</a></li>
|
||||
</ul>
|
||||
<center>
|
||||
<img src="imgs/img.gif"></img>
|
||||
<p>
|
||||
<a href="http://en.wikipedia.org/wiki/File:Newtons_cradle_animation_book_2.gif">Source</a>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<title>test-img.html </title>
|
||||
<body>
|
||||
<center><h1>Page de test simple + image</h1></center>
|
||||
<ul>
|
||||
<li><a href="test.html">Page de test simple</a></li>
|
||||
<li><a href="test-img.html">Page de test avec une image</a></li>
|
||||
<li><a href="test-img-css.html">Page de test avec CSS et image</a></li>
|
||||
</ul>
|
||||
<center>
|
||||
<img src="imgs/img.gif"></img>
|
||||
<p>
|
||||
<a href="http://en.wikipedia.org/wiki/File:Newtons_cradle_animation_book_2.gif">Source</a>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<title>test.html </title>
|
||||
<body>
|
||||
<center><h1>Page de test simple</h1></center>
|
||||
<ul>
|
||||
<li><a href="test.html">Page de test simple</a></li>
|
||||
<li><a href="test-img.html">Page de test avec une image</a></li>
|
||||
<li><a href="test-img-css.html">Page de test avec CSS et image</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue