Last active
November 4, 2018 14:21
-
-
Save cbetta/f1e03724c697fa517604b697dad8b7d2 to your computer and use it in GitHub Desktop.
Week 2 - Packages and a little simple server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<%= new Date().toLocaleString() %> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<%= name %> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
Hello World | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm init | |
npm install express --save | |
touch week2.app.js | |
npm install -g nodemon | |
nodemon week2.app.js | |
npm install ejs --save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
const port = 3000 | |
app.get('/', (request, response) => { | |
response.send('Hello World!') | |
}) | |
const path = require('path') | |
app.get('/file', (request, response) => { | |
response.sendFile(path.join(__dirname + '/views/index.html')) | |
}) | |
app.set('views', path.join(__dirname, 'views')); | |
app.set('view engine', 'ejs') | |
app.get('/date', (request, response) => { | |
response.render('date') | |
}) | |
app.get('/hello/:name', (request, response) => { | |
response.render('hello', request.params) | |
}) | |
app.listen(port, () => { | |
console.log("Server started") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment