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
30 changes: 30 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express');
const path = require('path');

const app = express();

// Set up middleware to serve static files
app.use(express.static(path.join(__dirname, 'public')));

// Define routes
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('/works', (req, res) => {
res.sendFile(path.join(__dirname, 'views/works.html'));
});

app.get('/gallery', (req, res) => {
res.sendFile(path.join(__dirname, 'views/gallery.html'));
});

// Start the server
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${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.21.1"
}
}
42 changes: 42 additions & 0 deletions public/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
text-align: center;
}

h1 {
color: #333;
}

nav ul {
list-style-type: none;
padding: 0;
}

nav ul li {
display: inline;
margin: 0 15px;
}

nav ul li a {
text-decoration: none;
color: #007BFF;
}

nav ul li a:hover {
text-decoration: underline;
}

.gallery img {
width: 200px;
height: auto;
margin: 10px;
border: 2px solid #ddd;
border-radius: 5px;
}

.gallery img:hover {
border-color: #007BFF;
}

Binary file added public/images/photo1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/photo2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/photo3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions views/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About</title>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<h1>About Me</h1>
<p>This page contains some basic information about the person.</p>
<a href="/">Back to Home</a>
</body>
</html>
18 changes: 18 additions & 0 deletions views/gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gallery</title>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<h1>Photo Gallery</h1>
<div class="gallery">
<img src="/images/photo1.jpg" alt="Photo 1">
<img src="/images/photo2.jpg" alt="Photo 2">
<img src="/images/photo3.jpg" alt="Photo 3">
</div>
<a href="/">Back to Home</a>
</body>
</html>
19 changes: 19 additions & 0 deletions views/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<h1>Welcome to My Website!</h1>
<nav>
<ul>
<li><a href="/about">About</a></li>
<li><a href="/works">Works</a></li>
<li><a href="/gallery">Gallery</a></li>
</ul>
</nav>
</body>
</html>
19 changes: 19 additions & 0 deletions views/works.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Works</title>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<h1>My Works</h1>
<p>Here are some of my amazing works:</p>
<ul>
<li>Project 1</li>
<li>Project 2</li>
<li>Project 3</li>
</ul>
<a href="/">Back to Home</a>
</body>
</html>