Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -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}`);
});
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "lab-express-basic",
"version": "1.0.0",
"description": "<img src=\"https://imgur.com/XOS1Vdh.png\" width=\"150px\" height=\"150px\">",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.19.2"
}
}
Empty file added public/style.css
Empty file.
28 changes: 28 additions & 0 deletions views/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About Page</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<header>
<h1>About Me</h1>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/work">Works</a></li>
<li><a href="/gallery">Photo Gallery</a></li>
</ul>
</nav>
<main>
<p>This is some basic information about me.</p>
</main>
<footer>
<p>&copy;Contact for further information</p>
</footer>
</body>
</html>
28 changes: 28 additions & 0 deletions views/gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Photo Gallery Page</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<header>
<h1>Photo Gallery</h1>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/work">Works</a></li>
<li><a href="/gallery">Photo Gallery</a></li>
</ul>
</nav>
<main>
<p>This is the photo gallery section.</p>
</main>
<footer>
<p>&copy; XYZ 2024</p>
</footer>
</body>
</html>
28 changes: 28 additions & 0 deletions views/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/work">Works</a></li>
<li><a href="/gallery">Photo Gallery</a></li>
</ul>
</nav>
<main>
<p>Welcome to my website! Feel free to explore the pages.</p>
</main>
<footer>
<p>&copy; XYZ 2024</p>
</footer>
</body>
</html>
28 changes: 28 additions & 0 deletions views/work.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Works Page</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<header>
<h1>My Works</h1>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/work">Work</a></li>
<li><a href="/gallery">Photo Gallery</a></li>
</ul>
</nav>
<main>
<p>This is where I showcase some of my work.</p>
</main>
<footer>
<p>&copy; XYZ 2024</p>
</footer>
</body>
</html>