Не попадитесь на накрученные каналы! Узнайте, не накручивает ли канал просмотры или
подписчиков
Проверить канал на накрутку
Телеграм канал «Coding Free Books | Python | AI»
Coding Free Books | Python | AI
1.6K
0
109
100
1.8K
Best Channel for Programmers and Hackers All in one channel to learn 👇 1. Python 2. Ethical Hacking 3. Java 4. App development 5. Machine learning 6. Data structures 7. Algorithms
Node.js lets you run JavaScript on the server side, making it great for building fast, scalable backend applications. 🚀
1️⃣ What is Node.js?
Node.js is a runtime built on Chrome's V8 JavaScript engine. It enables running JS outside the browser, mainly for backend development. 🖥️
2️⃣ Why Use Node.js?
- Fast & non-blocking (asynchronous) ⚡
- Huge npm ecosystem 📦
- Same language for frontend & backend 🔄
- Ideal for APIs, real-time apps, microservices 💬
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(3000, () => console.log('Server running on port 3000'));
7️⃣ Working with JSON & APIs:
app.use(express.json()); // Middleware to parse JSON body
app.post('/data', (req, res) => {
console.log(req.body); // Access JSON data from request body
res.send('Received!');
});
8️⃣ File System Module (fs):
const fs = require('fs');
fs.readFile('file.txt', 'utf8', (err, data) => {
if (err) throw err;
console.log(data); // Content of file.txt
});
9️⃣ Middleware in Express:
Functions that run before reaching the route handler.
app.use((req, res, next) => {
console.log('Request received at:', new Date());
next(); // Pass control to the next middleware/route handler
});