nodejs/tests/resources/server2.js
Petr "Stone" Hracek 943bed62f1 First set of tests.
Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
2017-06-09 10:41:43 +02:00

27 lines
481 B
JavaScript

const http = require('http');
const fs = require('fs');
const port = 8080;
string = "ERROR"
fs.readFile('/tmp/test/hello.txt','utf-8', function (err,data) {
if (err) {
console.log("Error");
}
else
{
string = data;
}
});
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end(string);
});
server.listen(port, () => {
console.log(`Server running at http://127.0.0.1:${port}/`);
});