-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (21 loc) · 776 Bytes
/
Copy pathserver.js
File metadata and controls
24 lines (21 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// server.js
const express = require('express');
const app = express();
const port = 3000;
// Example endpoint for fetching recipes
app.get('/api/recipes', async (req, res) => {
try {
// Replace with your logic to fetch recipes from a database or third-party API
const recipes = [
{ title: 'Pasta Carbonara', description: 'A classic Italian pasta dish made with eggs, cheese, pancetta, and pepper.' },
{ title: 'Chicken Curry', description: 'A flavorful chicken curry with a rich and spicy sauce.' },
// Add more recipes as needed
];
res.json(recipes);
} catch (error) {
res.status(500).json({ error: 'Error fetching recipes' });
}
});
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});