Skip to content

Instantly share code, notes, and snippets.

@iamPedroVictor
Created April 18, 2020 20:51
Show Gist options
  • Save iamPedroVictor/bb867c3929e7f8804fad7d67d4452548 to your computer and use it in GitHub Desktop.
Save iamPedroVictor/bb867c3929e7f8804fad7d67d4452548 to your computer and use it in GitHub Desktop.
const http = require('http');
const url = require('url');
const head = {
'Content-Type': 'text/html;charset=utf-8',
};
const HtmlHead = response => {
response.write('<head>');
response.write("<title>Webservice - Fametro</title>");
response.write('</head>');
};
const HtmlBody = (request, response) => {
response.write('<body>');
response.write('<h1>Hello World!</h1>');
response.write('<p>Nossa web service em node esta rodando.</p>');
response.write('<p>O caminho recebido: <b>' + request.url + '</b></p>');
response.write('<p>Faça mais testes, bons estudos</p>');
response.write('</body>');
};
const route = (req,res ) => {
res.writeHead(200, head);
HtmlHead(res);
HtmlBody(req,res);
res.end();
};
http.createServer(route).listen(8080, () => {
console.log("Rodando a aplicação na porta: " + 8080);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment