const http = require('http')
const fs=require('fs')

const server =http.createServer((req,res)=>{
    console.log(req.url,req.method);
fs.readFile('../pages/Giris.html',(err,data)=>{
    if(err){
        console.log(err);
        res.end()
    }
})
let sBody =`
<html>
<head>
    <title>Buldum Buldum | GİRİŞ</title>
   <!--  <link rel="stylesheet" href="../css/login.css"> -->
    <link rel="Shortcut Icon"  href="../imgs/kon.png"  type="image/x-icon" >
	<script src="../javascript/giris.js">
</script>
<style>
*{
    margin:0;
    padding: 0;
    text-decoration: none;
    font-family: sans-serif;
    box-sizing: border-box;
}
body{
    background-image:linear-gradient(120deg,rgb(0, 182, 167),rgb(0, 243, 211),white);/*karışık renk ekleme renkleri derece cinsinden karıştırarak basar*/
    min-height: 100vh;/*yükseklik*/
}

.panel{
    width: 350px;
    background: white;
    height: 380px;
    padding: 80px 40px;/*sağdan soldan 40px yukarıdan aşağıdan 80 px padding*/
    border-radius: 10px;/*köşleri ovalleştirme*/
    position: absolute;
    left: 500px;
    top: 100px;
    
}
.panel2{
    width: 350px;
    background: white;
    height: 500px;
    padding: 80px 40px;/*sağdan soldan 40px yukarıdan aşağıdan 80 px padding*/
    border-radius: 10px;/*köşleri ovalleştirme*/
    position: absolute;
    left: 500px;
    top: 100px;
}

.txtb{

     /*alt çizgi ekleme*/
    position: relative;
    margin: 30px 0;
}
.txtb input{
    font-size: 15px;
    color:#333;
    border: none;
    width: 100%;
    outline: none;
    background: none;
    padding: 0 5px;
    height: 40px;
	border-bottom: 2px solid #adadad;
}

.logbtn{
    display: block;
    width: 100%;
    height: 50px;
    border: none;
    background-image:linear-gradient(120deg,rgb(0, 182, 167),rgb(0, 243, 211),white);
    background-size: 200%;
    color: white;
    outline: none;/*köşelerini kapatmak siyah olmamsı için*/
    cursor: pointer;
	border-radius:15px;
}
.logbtn:hover{
	background:white;
	color:rgb(24, 185, 185);
    font-size: large;
	
}
.buldum{
    position: absolute;
    right: 75px;;
    top: 5px;
}
</style>
</head>
<body>
    
    <div class="panel">
        <div class="buldum"><a href="Giris.html"><img src="../imgs/icon.png" height="100" width="200"></a> </div>
        <div class="contact-form">
            <form>
                <div class="txtb">
                    <input id="Eposta" type="text" placeholder="E-posta" >
                </div>
                <div class="txtb">
                    <input id="sifre" type="password" placeholder="Şifre">
                </div>
                <input type="button" class="logbtn" value="Giriş Yap" onclick="giris()">
				<br><input type="button" class="logbtn" value="Kayıt Ol" onclick="window.location.href ='kayıtol.html';">
			</form>
        </div>
    </div>
</body>
</html>

`
})


function sayfa_yukle(req, res) {
    var pathname = url.parse(req.url).pathname;
    if (pathname == sayfa_isim) {
        fs.readFile("../pages" + pathname + ".html", "UTF-8", function (err, html) {
            res.writeHead(200, { "Content-Type": "text/html" });
            res.end(html);
        });
    } else if (pathname.match("\.css$")) {
        var cssPath = path.join(__dirname, "..", pathname);
        var fileStream = fs.createReadStream(cssPath, "UTF-8");
        res.writeHead(200, { "Content-Type": "text/css" });
        fileStream.pipe(res);
    } else if (pathname.match("\.png$")) {

        var imagePath = path.join(__dirname, "..", pathname);
        var fileStream = fs.createReadStream(imagePath);
        res.writeHead(200, { "Content-Type": "image/png" });
        fileStream.pipe(res);
    } else if (pathname.match("\.jpg$")) {

        var imagePath = path.join(__dirname, "..", pathname);
        var fileStream = fs.createReadStream(imagePath);
        res.writeHead(200, { "Content-Type": "image/jpg" });
        fileStream.pipe(res);
    }  
        
     else if (pathname.match("\.js$")) {
        var videoPath = path.join(__dirname, "..", pathname);
        var fileStream = fs.createReadStream(videoPath);
        res.writeHead(200, { "Content-Type": "text/javascript" });
        fileStream.pipe(res);
    } else {
        res.writeHead(404, { "Content-Type": "text/html" });
        res.end("Sayfa Bulunamadı");
    }
}



server.listen(8080,'localhost',()=>{
    console.log('SERVER CALİSTİİ');
})
