Skip to content

Commit

Permalink
server renders the readme instead of hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
superterran committed Aug 9, 2024
1 parent 1163dd4 commit a629bf1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"start:cloud": "PORT=8888 node server.js # We add this to start the server on port 8888"
"start:cloud": "PORT=8888 node server.js # We add this to start the server on port 8888"
},
"author": "Doug Hatcher",
"license": "MIT",
"dependencies": {
"express": "^4.19.2"
"express": "^4.19.2",
"fs": "^0.0.1-security",
"marked": "^14.0.0"
}
}
13 changes: 12 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
const express = require('express');
const fs = require('fs');
const marked = require('marked');
const app = express();

const port = process.env.PORT || 3000; // Use the PORT environment variable or default to 3000

app.get('/', (req, res) => {
res.send('Hello, World!');
fs.readFile('./README.md', 'utf8', (err, data) => {
if (err) {
console.error(err);
res.status(500).send('Error reading README.md');
} else {
var rawMarkup = marked.parse(data);

res.send(`${rawMarkup}`);
}
});
});

app.listen(port, () => {
Expand Down

0 comments on commit a629bf1

Please sign in to comment.