-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (20 loc) · 835 Bytes
/
Copy pathserver.js
File metadata and controls
40 lines (20 loc) · 835 Bytes
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
var fs= require('fs');
var data=fs.readFileSync('cv.json');//syncronous hasta que no termine no haga otra cosa al cargar el server es interesante que hasta q no arraque y cargue no haga nada mas
var cv=JSON.parse(data);
//console.log(cv);
console.log("server is starting...");
var express=require('express');//import
var port = process.env.PORT || 3000;
var app=express();//ejetupo express y ya tengo la web app
var server=app.listen(port,listening);//lisen for incoming conextions
function listening(){
console.log("listening in port "+port);
}
app.use(express.static('website'));//to have static files
//----------cv ------------------------
app.get('/cv',sendAll);
function sendAll(request,response){
var cvFormat=JSON.stringify(cv, null, 4);
response.send(cv);
}
//----------END ------------------------