Skip to content

Commit c394ecf

Browse files
committed
Fix dynamic server to be able to run from anywhere
1 parent 399e31f commit c394ecf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lesson03/exercise_004/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ const url = require('url');
88
const staticDir = path.resolve(`${__dirname}/static`);
99
console.log(`Static resources from ${staticDir}`);
1010

11-
const data = fs.readFileSync('products.json');
11+
const data = fs.readFileSync(`${__dirname}/products.json`);
1212
const products = JSON.parse(data.toString());
1313
console.log(`Loaded ${products.length} products...`);
1414

1515
handlebars.registerHelper('currency', (number) => `$${number.toFixed(2)}`);
1616

17-
const htmlString = fs.readFileSync('html/index.html').toString();
17+
const htmlString = fs.readFileSync(`${__dirname}/html/index.html`).toString();
1818
const template = handlebars.compile(htmlString);
1919
function handleProductsPage(requestUrl, response) {
2020
response.writeHead(200);

0 commit comments

Comments
 (0)