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();


app.use(express.static(path.join(__dirname, 'public')));

app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'views', 'index.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'));
});


const PORT = process.env.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.2"
}
}
40 changes: 40 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* styles.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}

header {
background-color: #333;
color: white;
padding: 10px;
text-align: center;
}

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

nav ul li {
display: inline;
margin-right: 20px;
}

nav ul li a {
color: white;
text-decoration: none;
}

main {
padding: 20px;
}

.gallery img {
width: 30%;
margin: 10px;
border: 2px solid #ddd;
padding: 5px;
}

26 changes: 26 additions & 0 deletions views/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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="/styles.css">
</head>
<body>
<header>
<h1>About Me</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/works">Works</a></li>
<li><a href="/gallery">Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>About the Person</h2>
<p>Here, you can add some information about the person. It could include their background, interests, and other relevant details.</p>
</main>
</body>
</html>
30 changes: 30 additions & 0 deletions views/gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!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="/styles.css">
</head>
<body>
<header>
<h1>Photo Gallery</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/works">Works</a></li>
<li><a href="/gallery">Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>Gallery of Images</h2>
<div class="gallery">
<img src="/images/photo1.jpg" alt="Image 1">
<img src="/images/photo2.jpg" alt="Image 2">
<img src="/images/photo3.jpg" alt="Image 3">
</div>
</main>
</body>
</html>
26 changes: 26 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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="/styles.css">
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/works">Works</a></li>
<li><a href="/gallery">Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>Welcome to the Home Page!</h2>
<p>This is a simple website built using Express.js.</p>
</main>
</body>
</html>
30 changes: 30 additions & 0 deletions views/works.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!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="/styles.css">
</head>
<body>
<header>
<h1>Works</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/works">Works</a></li>
<li><a href="/gallery">Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>Here are some of the works:</h2>
<ul>
<li>Project 1: Description</li>
<li>Project 2: Description</li>
<li>Project 3: Description</li>
</ul>
</main>
</body>
</html>