,

एक्सप्रेस जेएस और नोड जेएस में ब्लॉग एप्लिकेशन | हिंदी में | लेक्चर ७८ | @दकोड्थ्रेड

Posted by


Namaste dosto! Aaj hum baat karenge Express js aur Node js ke bare mai, specifically Part 2 mai jisme hum ek blog app create karenge. Ye tutorial Lec 78 hai, jise main @thecodethread dwara provide kiya gaya hai.

Toh chaliye shuru karte hain!

Step 1: Sabse pehle, apne terminal mai jaakar naya folder create karein jisme hum apna project setup karenge. Iske liye niche diye gaye command ka use karein:

mkdir blog-app
cd blog-app

Step 2: Ab project ko initialize karne ke liye npm init command ka use karein aur saare options ko fill karein jo prompt kiya jayega.

npm init

Step 3: Ab hum Express js aur Node js ko install karenge apne project mai. Niche diye gaye commands ka use karein:

npm install express
npm install nodemon

Step 4: Ab hum apne project ke root directory mai ek server file create karenge jisme hum Express js ka use karenge. Niche diye gaye code ka use karein:

const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.send('Hello, World!');
});

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

Step 5: Ab hum apne package.json file mai ek script add karenge jisse hum server ko start kar sakein. Niche diye gaye code ko add karein:

"scripts": {
  "start": "nodemon server.js"
}

Step 6: Ab hum server ko start karne ke liye terminal mai niche diye gaye command ka use karein:

npm start

Step 7: Agar server successfully run ho gaya hai, toh ab hum browser mai jaakar http://localhost:3000/ par jaakar ‘Hello, World!’ message dekh sakte hain.

Step 8: Ab hum ek basic blog app create karenge jisme hum posts show karenge. Iske liye, hum apne server file mai ek dummy data array define karenge. Niche diye gaye code ko add karein:

const posts = [
  { title: 'First Post', body: 'Lorem ipsum dolor sit amet'},
  { title: 'Second Post', body: 'consectetur adipiscing elit'}
];

Step 9: Ab hum Express js ka use karke ye data render karenge. Niche diye gaye code ka use karein iske liye:

app.get('/posts', (req, res) => {
  res.json(posts);
});

Step 10: Ab hum browser mai jaakar http://localhost:3000/posts par jaakar hum apne posts ke data ko dekh sakte hain.

Umeed hai ki aapko ye tutorial accha laga hoga. Agar aapko koi bhi help chahiye ya kuch samajh nahi aaya toh niche comment section mai likh sakte hain.

Dhanyawaad!

0 0 votes
Article Rating
5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@All4You22
1 month ago

Brother, please complete the mern series as soon as possible and please start and introduce database too like mysql and mongoDB please

@Ritesh_gurjar9900
1 month ago

Bhai aapki tarah mera ek channel hai new uska naam hai Ritesh Gurjar

@PuneshwarLondhe
1 month ago

bhai Angular bhi pada do

@AbdulRehman-bu3ho
1 month ago

I usually don’t comment on youtube but your content is so rich that I couldn’t hold myself

I found your channel through Swiggy Project.

mujhe pahle ase lagta tha mujhe javascript ati hai but after watching some of your javascript videos (advance wale topics) I'm totally amazed. your content is supreme quality.

mane ek paid course se full stack padhi hai. course accha tha but backend mai kuch smjh nahi aya

now I'm following your backend playlist.

Thank you from the bottom of my heart for teaching with such great detail and clarity.

@Sjjsjam
1 month ago

bahiya ajj apka youtube channel sa mern start karna ja raha hu i am sad pata nahi youtube muja asa channel recommend kyo nahi karta hai