Skip to content

Conversation

njood8
Copy link

@njood8 njood8 commented Jul 6, 2025

const express = require('express');
const path = require('path');
const app = express();

// السماح للملفات الثابتة
app.use(express.static(__dirname));

// للسماح بقراءة JSON من body
app.use(express.json());

// عرض الصفحة الرئيسية
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'home.html'));
});

// ✅ هنا الباكند اللي يتلقى البيانات
app.post('/api/hello', (req, res) => {
const name = req.body.name;
res.json({ message: 👋 Hello, ${name}! });
});

const port = 3000;
app.listen(port, () => {
console.log(✅ Server is running at http://localhost:${port});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant