-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
40 lines (34 loc) · 1 KB
/
Copy pathtest.js
File metadata and controls
40 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Dependencias
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
// Parsear o conteudo
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
// Configuração da requisição, cabeçalhos, CORS
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
// Métodos que queremos permitir
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
// GET
app.get('/',function(req,res){
var body = '<html>'
+' <head>'
+' <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>'
+' </head>'
+' <body>'
+ '<h1>Bem vindo Cloud Ninja</h1>'
+' </body>'
+'</html>';
res.writeHead(200,{"Content-Type" : "text/html"});
res.write(body);
res.end();
});
app.listen(8080,function(){
console.log("Conectado e escutando na porta 8080");
});