Created
May 4, 2021 13:59
-
-
Save ng-the-engineer/be289bca21dc9138034bf353978cfe17 to your computer and use it in GitHub Desktop.
Code snippet of tutorial node api k8s
This file contains hidden or 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
const express = require("express"); | |
const fs = require("fs"); | |
const path = require("path"); | |
const app = express(); | |
const port = 3001; | |
app.get("/skills", (req, res) => { | |
fs.readFile( | |
path.join(__dirname, "/skills.csv"), | |
{ encoding: "utf-8" }, | |
(err, file) => { | |
if (err) console.log(err); | |
res.setHeader("Access-Control-Allow-Origin", "*"); | |
res.setHeader("Access-Control-Allow-Methods", "POST, GET"); | |
res.setHeader("Access-Control-Allow-Headers", "Content-Type"); | |
res.send(file); | |
} | |
); | |
}); | |
app.listen(port, () => { | |
console.log(`App is listening on port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment