├── package.json ├── app.js ├── index.html └── about.html /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exp5", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "", 9 | "license": "ISC", 10 | "description": "", 11 | "dependencies": { 12 | "express": "^4.19.2" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const path = require('path'); 3 | const app = express(); 4 | const port = 3000; 5 | 6 | // Serve static files from the 'public' directory 7 | app.use(express.static(path.join(__dirname, 'public'))); 8 | 9 | // Route for '/' 10 | app.get('/', (req, res) => { 11 | res.sendFile(path.join(__dirname, 'Public', 'index.html')); 12 | }); 13 | 14 | // Route for '/about' 15 | app.get('/about', (req, res) => { 16 | res.sendFile(path.join(__dirname, 'Views', 'about.html')); 17 | }); 18 | 19 | app.listen(port, () => { 20 | console.log(`Server running at http://localhost:${port}/`); 21 | }); 22 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |54 | This is the homepage of our Express.js application. Express.js is a minimal and 55 | flexible Node.js web application framework 56 | that provides a robust set of features for building web and mobile applications. It 57 | simplifies the process of routing, 58 | handling requests, and serving static files. 59 |
60 |61 | Click here to learn more about Express.js. 62 |
63 |51 | Express.js is a popular web application framework for Node.js. It provides a 52 | minimal and flexible set of tools for building web applications and APIs. Express simplifies the process of routing, handling 53 | HTTP requests, and managing middleware, making it easier to build robust and scalable web applications. 54 |
55 |56 | Express is known for its simplicity and ease of use, and it is a key component of the 57 | MEAN (MongoDB, Express, Angular, Node.js) and MERN (MongoDB, Express, React, Node.js) stacks. 58 |
59 |60 | Click here to return to the homepage. 61 |
62 |