Skip to content

Instantly share code, notes, and snippets.

@rezwan-hossain
Last active October 10, 2017 06:37
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 rezwan-hossain/fc318fc3ebad5ff5f49a9bf993cb8f4d to your computer and use it in GitHub Desktop.
Save rezwan-hossain/fc318fc3ebad5ff5f49a9bf993cb8f4d to your computer and use it in GitHub Desktop.
Render basic html file and folder in express
<!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>
<h1>hello World</h1>
</body>
</html>
{
"name": "htmlRender",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"express": "^4.15.3"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
const express = require('express');
const path = require('path')
const app = express();
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res) {
//res.sendFile(__dirname +'/index.html');
});
app.listen(3000, function() {
console.log('App listening on port 3000!');
});
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.sendFile(__dirname +'/index.html');
});
app.listen(3000, function() {
console.log('App listening on port 3000!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment