Skip to content

Commit

Permalink
Modificación de archivos
Browse files Browse the repository at this point in the history
Modificación de archivos
  • Loading branch information
fhernandezpalafox committed Sep 10, 2017
1 parent 6324e5d commit 2478eba
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 18 deletions.
33 changes: 24 additions & 9 deletions Node6/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ var mime = {
};



var servidor = http.createServer(function(request,response){

var objUrl = url.parse(request.url);
var objUrl = url.parse(request.url);

var path = 'pages'+objUrl.pathname;

Expand All @@ -28,9 +29,10 @@ var servidor = http.createServer(function(request,response){
path = 'pages/index.html';
}else if (path == "pages/acceso"){
acceso(request, response);
return;
return false;
}




//Verificacion de que si esta el archivo en la ruta
fs.exists(path, function(existe){
Expand Down Expand Up @@ -71,14 +73,16 @@ var servidor = http.createServer(function(request,response){
response.end();
}
});


});

});


function acceso(request, response){
var informacion = "";

request.on("data", function(datos){
console.log(datos);
informacion += datos;
});

Expand All @@ -89,10 +93,21 @@ function acceso(request, response){

var formulario = querystring.parse(informacion);

var pagina = "<html><head><body>"+
"Nombre de usuario: "+formulario["usuario"]+"<br/>"+
"Clave: "+formulario["pass"]+""+
"</body></head></html>";
console.log(formulario);

var pagina ="";

if (formulario["usuario"] != undefined && formulario["pass"] != undefined) {

pagina = "<html><head><body>"+
"Nombre de usuario: "+formulario["usuario"]+"<br/>"+
"Clave: "+formulario["pass"]+""+
"</body></head></html>";
}else {
pagina = "<html><head><body>Debes poner tus credenciales primero</body></head></html>";
}



response.writeHead(200,{"content-type":"text/html"});
response.end(pagina);
Expand Down
16 changes: 13 additions & 3 deletions Node7/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var servidor = http.createServer(function(request,response){
path = 'pages/index.html';
}else if (path == "pages/tablaMultiplicar"){
tablaMultiplicar(request, response);
return;
return false;
}


Expand Down Expand Up @@ -80,11 +80,21 @@ function tablaMultiplicar(request, response){

var tablaAMultiplicar = url.parse(request.url,true).query.numero;
console.log(tablaAMultiplicar);
var pagina = "<html><head><body>";

var pagina ="";

if (!isNaN(tablaAMultiplicar)) //Not a Number = NaN
{
pagina = "<html><head></head><body>";
for (var i = 1; i <= 10; i++) {
pagina += ""+tablaAMultiplicar+"x"+i+"="+(tablaAMultiplicar * i)+"<br/>";
}
pagina += "</body></head></html>";
pagina += "</body></html>";
}else {

pagina = "<html><head></head><body>No es numero lo que estas pasando</body></html>";
}


response.writeHead(200,{"content-type":"text/html"});
response.end(pagina);
Expand Down
4 changes: 2 additions & 2 deletions Node8/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var upperCase = require('upper-case');
var servidor = http.createServer(function(req,resp){

resp.writeHead(200,{'Content-Type':'text/html'});
resp.write('<html><head><body> Mi nombre es felipe y en mayusculas es: '+upperCase("felipe")+'</body></head></html>');
resp.write('<html><head></head><body> Mi nombre es felipe y en mayusculas es: '+upperCase("felipe")+'</body></html>');
//N(n)
resp.end();

Expand All @@ -14,4 +14,4 @@ var servidor = http.createServer(function(req,resp){

servidor.listen(8000);

console.log("Servidor Iniciado");
console.log("Servidor Iniciado");
4 changes: 2 additions & 2 deletions Node8/node_modules/upper-case/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Node8/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "node8",
"version": "1.0.0",
"description": "Ejemplo del uso de los paquetes npm",
"main": "index.js",
"description": "ejercicio conociendo npm",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down

0 comments on commit 2478eba

Please sign in to comment.