Skip to content
Open

done #39

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

const app = express();
const port = 4000;

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.listen(port, () => {
console.log(`Server is running at 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.19.2"
}
}
19 changes: 19 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
text-align: center;
}

nav a {
margin: 0 15px;
text-decoration: none;
color: #007BFF;
}

.gallery img {
width: 200px;
height: auto;
margin: 10px;
}

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/style.css">
</head>
<body>
<h1>About Me</h1>
<p>This is the about page.</p>
<a href="/">Back to Home</a>
</body>
</html>
17 changes: 17 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!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/style.css">
</head>
<body>
<h1>Welcome to My Website!</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/works">Works</a>
</nav>
</body>
</html>
14 changes: 14 additions & 0 deletions views/works.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>Works</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<h1>My Works</h1>
<p>Here are some of my works.</p>
<a href="/">Back to Home</a>
</body>
</html>