how to render in node js code example
Example 1: render html in node js
render html in node js
-----------------------------
//server.js & index.html keep in same dir
app.use(express.static('./'));
app.get('/', function(req, res) {
res.render('index.html');
});
Example 2: how to render different pages in nodes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/Static/css/spaceGame.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400" rel="stylesheet">
<title>{{title}}</title>
</head>
<body>
{{{body}}}
<script src="https://unpkg.com/vue"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/Static/script/someTest.js"></script>
</body>
</html>