merhaba node.js de dosyamı düzenledim ancak ne yaparsam yapayım boş sayfa alıyorum konsolda veri yok hata yok server dosyasını aşağıya bırakıyorum
const express = require('express');
const axios = require('axios');
const path = require('path');
const app = express();
app.use(express.json());
// Public klasör kontrolü
const fs = require('fs');
if (fs.existsSync('public')) {
    app.use(express.static('public'));
    console.log('✅ Public klasörü bulundu');
} else {
    console.log('⚠️ Public klasörü bulunamadı, sadece API route\'ları çalışacak');
}
const sessions = new Map();

// JSON ve URL encoded parser
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// ✅ CRITICAL: Static dosyalar için doğru ayar
app.use(express.static(path.join(__dirname, 'public'), {
    index: 'index.html',
    extensions: ['html', 'htm'],
    setHeaders: (res, filePath) => {
        console.log(`📁 Static file served: ${filePath}`);
    }
}));
// ✅ PUBLIC KLASÖR KONTROLÜ
const publicPath = path.join(__dirname, 'public');
const indexPath = path.join(publicPath, 'index.html');
console.log('🔍 Dosya kontrolleri:');
console.log(`- Public klasörü: ${publicPath}`);
console.log(`- index.html yolu: ${indexPath}`);
console.log(`- Public klasörü var mı: ${fs.existsSync(publicPath)}`);
console.log(`- index.html var mı: ${fs.existsSync(indexPath)}`);
// ✅ ANA SAYFA ROUTE'U - Geliştirilmiş
app.get('/sd', (req, res) => {
    console.log('Ana sayfa isteği alındı');
    res.send('Basit bir metin cevabı');
});
app.get('/ds', (req, res) => {
    res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.get('/dee', (req, res) => {
    const filePath = path.join(__dirname, 'public', 'index.html');
    console.log('Dosya yolu:', filePath);
    
    // Dosyanın var olup olmadığını kontrol et
    if (fs.existsSync(filePath)) {
        console.log('Dosya bulundu, gönderiliyor...');
        res.sendFile(filePath, (err) => {
            if (err) {
                console.error('Dosya gönderilirken hata oluştu:', err);
                res.status(500).send('Dosya gönderilemedi.');
            } else {
                console.log('Dosya başarıyla gönderildi.');
            }
        });
    } else {
        console.error('Dosya bulunamadı:', filePath);
        res.status(404).send('Dosya bulunamadı.');
    }
});
app.get('/test', (req, res) => {
    res.send(`
        <!DOCTYPE html>
        <html>
        <head>
            <title>Test HTML</title>
            <style>
                body { font-family: Arial; margin: 40px; background: #f0f0f0; }
                .test { background: white; padding: 20px; border-radius: 10px; }
            </style>
        </head>
        <body>
            <div class="test">
                <h1 style="color: green;">✅ HTML ÇALIŞIYOR!</h1>
                <p>Eğer bu görünüyorsa, Express HTML gönderebiliyor.</p>
                <p>Zaman: ${new Date().toLocaleString('tr-TR')}</p>
                <a href="/">Ana Sayfaya Git</a>
            </div>
        </body>
        </html>
    `);
});