deployed test app from node.js samples
This commit is contained in:
25
index.js
Normal file
25
index.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import http from "http";
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const server = http.createServer((req, res) => {
|
||||||
|
const filePath = path.join(__dirname, "message.txt");
|
||||||
|
|
||||||
|
fs.readFile(filePath, "utf8", (err, data) => {
|
||||||
|
if (err) {
|
||||||
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
||||||
|
res.end("Error reading file");
|
||||||
|
} else {
|
||||||
|
res.writeHead(200, { "Content-Type": "text/plain" });
|
||||||
|
res.end(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(3000, () => {
|
||||||
|
console.log("Server is running on port 3000");
|
||||||
|
});
|
||||||
1
message.txt
Normal file
1
message.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Testing node.js app deployed via platform
|
||||||
Reference in New Issue
Block a user