From 8021d382d2aa072e40164fdf2da1b0f05a46ed9c Mon Sep 17 00:00:00 2001 From: Sahil Date: Wed, 12 Jun 2024 23:23:10 +0530 Subject: [PATCH] Solved lab --- app.js | 31 +++++++++++++++++++++++++++++++ package.json | 15 +++++++++++++++ public/style.css | 0 views/about.html | 28 ++++++++++++++++++++++++++++ views/gallery.html | 28 ++++++++++++++++++++++++++++ views/home.html | 28 ++++++++++++++++++++++++++++ views/work.html | 28 ++++++++++++++++++++++++++++ 7 files changed, 158 insertions(+) create mode 100644 package.json create mode 100644 public/style.css create mode 100644 views/about.html create mode 100644 views/gallery.html create mode 100644 views/home.html create mode 100644 views/work.html diff --git a/app.js b/app.js index e69de29..1644806 100644 --- a/app.js +++ b/app.js @@ -0,0 +1,31 @@ +const express = require('express'); +const path = require('path'); + +const app = express(); +const PORT = process.env.PORT || 3000; + +// Serve static files from the public directory +app.use(express.static(path.join(__dirname, 'public'))); + +// Set up routes to serve HTML files +app.get('/', (req, res) => { + res.sendFile(path.join(__dirname, 'views', 'home.html')); +}); + +app.get('/about', (req, res) => { + res.sendFile(path.join(__dirname, 'views', 'about.html')); +}); + +app.get('/work', (req, res) => { + res.sendFile(path.join(__dirname, 'views', 'work.html')); +}); + +// (Optional) Add route for the photo gallery page +app.get('/gallery', (req, res) => { + res.sendFile(path.join(__dirname, 'views', 'gallery.html')); +}); + +// Start the server +app.listen(PORT, () => { + console.log(`Server is running on port ${PORT}`); +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..8fddf73 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "lab-express-basic", + "version": "1.0.0", + "description": "", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.19.2" + } +} diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..e69de29 diff --git a/views/about.html b/views/about.html new file mode 100644 index 0000000..6d2483f --- /dev/null +++ b/views/about.html @@ -0,0 +1,28 @@ + + + + + + About Page + + + +
+

About Me

+
+ +
+

This is some basic information about me.

+
+ + + \ No newline at end of file diff --git a/views/gallery.html b/views/gallery.html new file mode 100644 index 0000000..5194ae9 --- /dev/null +++ b/views/gallery.html @@ -0,0 +1,28 @@ + + + + + + Photo Gallery Page + + + +
+

Photo Gallery

+
+ +
+

This is the photo gallery section.

+
+ + + \ No newline at end of file diff --git a/views/home.html b/views/home.html new file mode 100644 index 0000000..7e65ab5 --- /dev/null +++ b/views/home.html @@ -0,0 +1,28 @@ + + + + + + Home Page + + + +
+

Welcome to My Website

+
+ +
+

Welcome to my website! Feel free to explore the pages.

+
+ + + \ No newline at end of file diff --git a/views/work.html b/views/work.html new file mode 100644 index 0000000..c135144 --- /dev/null +++ b/views/work.html @@ -0,0 +1,28 @@ + + + + + + Works Page + + + +
+

My Works

+
+ +
+

This is where I showcase some of my work.

+
+ + + \ No newline at end of file