
console.log("Hola mundo!");> node hola.js
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hola Mundo!\n');
}).listen(8000);
console.log('Server running at http://127.0.0.1:8000/'); var net = require('net');
net.createServer(function (stream) {
stream.write('Hola mundo!\r\n');
stream.on('end', function () {
stream.end('Adiós!\r\n');
});
stream.pipe(stream);
}).listen(7000);
> npm help
> npm install express> npm install express -g
> sudo npm install express -g > npm update > npm uninstall express > npm link colors > npm install colors --save
{
"name": "hola-mundo",
"dependencies" : {
"colors" : "*"
}
}
require("colors")
console.log("Hola mundo rojo!".red);
console.log("Hola mundo verde!".green);
console.log("Hola mundo azul!".blue);
> npm install> node hola.js
> npm install express -g
> express demoapp
> npm install> node app
> npm install supervisor -g> supervisor -w routes,app.js app.js
htmlbody#contenedorp Algo de texto.camposlabel(for="uncampo") Label del campoinput#uncampo(name="campo")
html
body
amigos = 10
case amigos
when 0
p No tienes amigos
when 1
p Tienes un amigo
default
p Tienes #{amigos} amigosinput(type='checkbox', name='agreement', checked)input(type='checkbox', name='agreement', checked)input(type='checkbox' name='agreement' checked)input( type='checkbox' name='agreement' checked)
doctype!!!doctype transitional!!! transitionaldoctype 5!!!5
elementos = ["un", "dos", "tres"] each elemento,i in elementos li #{elemento}: #{i}obj = { foo: 'bar' } each val, key in obj li #{key}: #{val}
for user in users
unless user.isAnonymous
if user.role == 'admin'
p #{user.name} is an admin
else
p= user.name html
head
h1 My sitio - #{title}
block scripts
script(src='/jquery.js')
body
block content
block foot
#footer
p El contenido del pie extends layout
block scripts
script(src='/jquery.js')
script(src='/mascotas.js')
block content
h1= title
each mascota in mascotas
include mascota block scripts
script(src='/jquery.js')
script(src='/mascotas.js')
block prepend scripts
script(src='/otro.js')
block append scripts
script(src='/mascotas.js') mixin mascotas(listadoMascotas)
ul.mascotas
- each mascota in listadoMascotas
li= mascota > npm install http-proxy var httpProxy = require('http-proxy');
httpProxy.createServer(function (req, res, proxy) {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 3000
});
}).listen(8002); > npm install -g yo grunt-cli bower > npm install -g generator-angular> yo webapp> yo angular #para crear una app angular
> bower install lodash> grunt server> grunt test> grunt jade #si agregamos como tarea nuestra