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
32 changes: 32 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// app.js

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
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'));
});

// Start the server
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"
}
}
41 changes: 41 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* public/styles.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}

header {
background-color: #4CAF50;
color: white;
padding: 15px;
}

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

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

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

main {
padding: 20px;
}

.gallery {
display: flex;
flex-wrap: wrap;
}

.gallery img {
width: 200px;
margin: 10px;
}
27 changes: 27 additions & 0 deletions views/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- views/about.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles.css">
<title>About</title>
</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">Photo Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>My Background</h2>
<p>Here is some information about me...</p>
</main>
</body>
</html>
32 changes: 32 additions & 0 deletions views/gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- views/gallery.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles.css">
<title>Photo Gallery</title>
</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">Photo Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>Gallery</h2>
<p>Here are some pictures...</p>
<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>
</main>
</body>
</html>
27 changes: 27 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- views/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles.css">
<title>Home</title>
</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">Photo Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>Welcome!</h2>
<p>This website showcases some of my work. Feel free to explore!</p>
</main>
</body>
</html>
27 changes: 27 additions & 0 deletions views/works.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- views/works.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles.css">
<title>Works</title>
</head>
<body>
<header>
<h1>My 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">Photo Gallery</a></li>
</ul>
</nav>
</header>
<main>
<h2>Projects</h2>
<p>Here are some of my projects...</p>
</main>
</body>
</html>