Created
April 18, 2018 07:34
-
-
Save TheCodingLady/ed8e16686f4a4f5d19d24a974bb09043 to your computer and use it in GitHub Desktop.
QUETE-NodeJS-HTTP-server-usingEJS
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
<!-- views/pages/about.ejs --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<% include ../partials/head %> | |
</head> | |
<body class="container"> | |
<header> | |
<% include ../partials/header %> | |
</header> | |
<main> | |
<div class="row"> | |
<div class="col-sm-4"> | |
<div class="jumbotron"> | |
<a href="#" class="thumbnail"> | |
<img src="http://res.cloudinary.com/agent99/image/upload/v1524004452/wcs%20random/mongoose.jpg" alt=""/></a> | |
</div> | |
</div> | |
<div class="col-sm-8"> | |
<div class="well"> | |
<h3>It has been 7 and 1/2 weeks of coding. So what do I know?</h3> | |
<h4>I know about ... </h4> | |
<ul> | |
<li>html and css powered with Bootstrap</li> | |
<li>using linux</li> | |
<li>more and more javascript</li> | |
<li>using EJS template engine</li> | |
<li>using web app tools such as Angular and Express</li> | |
<li>some SQL (Finally! This was a career goal previously.)</li> | |
<li>and more ... (but it's past midnight as I am writing this and I need to sleep)</li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
</main> | |
<footer> | |
<% include ../partials/footer %> | |
</footer> | |
</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
<!-- I used EJS (template engine) --> | |
<!-- views/pages/index.ejs --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<% include ../partials/head %> | |
</head> | |
<body class="container"> | |
<header> | |
<% include ../partials/header %> | |
</header> | |
<main> | |
<div class="jumbotron"> | |
<h1>What on earth?</h1> | |
<br/> | |
<p>Welcome to my wonderful world of coding!</p> | |
</div> | |
</main> | |
<footer> | |
<% include ../partials/footer %> | |
</footer> | |
</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
{ | |
"name": "queteproject", | |
"version": "1.0.0", | |
"main": "server.js", | |
"dependencies": { | |
"ejs": "^2.5.5", | |
"ejs-lint": "^0.3.0", | |
"express": "^4.16.3", | |
"jshint": "^2.9.5" | |
} | |
} |
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
// server.js | |
// load the things we need | |
var express = require('express'); | |
var app = express(); | |
// set the view engine to ejs | |
app.set('view engine', 'ejs'); | |
// use res.render to load up an ejs view file | |
// index page | |
app.get('/', function (req, res) { | |
res.render('pages/index', { | |
}); | |
}); | |
// about page | |
app.get('/about', function (req, res) { | |
res.render('pages/about', { | |
}); | |
}); | |
app.listen(3000); | |
console.log('3000 is the magical port'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment