Skip to content

Instantly share code, notes, and snippets.

@writingdeveloper
Created November 28, 2017 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save writingdeveloper/ff2d3260178c8b3315c6db605ba41ca3 to your computer and use it in GitHub Desktop.
Save writingdeveloper/ff2d3260178c8b3315c6db605ba41ca3 to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res) {
res.send('Hello home page');
});
app.get('/dynamic', function(req, res) {
var lis = '';
for (var i = 0; i < 5; i++) {
lis = lis + '<li>coding</li>';
}
var time = Date();
var output = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
Hello, Dynamic!
<ul>
${lis}
</ul>
${time}
</body>
</html>`;
res.send(output);
});
app.get('/route', function(req, res) {
res.send('Hello Router, <img src="/image.png">')
})
app.get('/login', function(req, res) {
res.send('<h1>Login please</h1>');
});
app.listen(3000, function() {
console.log('Conneted 3000 port!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment