Skip to content

Instantly share code, notes, and snippets.

@josegoyo
Last active April 25, 2016 06:35
Show Gist options
  • Select an option

  • Save josegoyo/2d0b1919a1deb0414ac2ce77731f2f74 to your computer and use it in GitHub Desktop.

Select an option

Save josegoyo/2d0b1919a1deb0414ac2ce77731f2f74 to your computer and use it in GitHub Desktop.

Para recibir parametros en el servidor de nodejs puro, es necesario agragar la libreria url como en el siguiente ejemplo

var http = require('http');
var url = require('url');

http.createServer(
    function (request, response) {
        response.writeHead(200, {'Content-Type':'text/plain'});
        
        var params = url.parse(request.url,true).query;       
        var yourName = new String(params.name);
        var yourLastName = new String(params.lasname);
       
        
        response.write('Hello, your name is: ' + yourName +' '+yourLastName);
        
        response.end();
    }
).listen(8000);

console.log("Servidor iniciado...");

url: http://localhost:8000/?name=jose&lasname=gregorio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment