CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 01:08:17 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=7613bcafc6a42bce394140f78acb973eb038663a2e9eeacd21a4492cf93837b4a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22H38Rm2QSStuZu1maeFdiwDaF12tRg5xg%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d2b486b9ff8a2a-BLR
Servidor en Node Js - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index.js
- var server = require ("./server");
- var router = require ("./routers");
- var requestHandlers = require ("./requestHandlers");
- var handle ={}
- handle ["/"] = requestHandlers.raiz;
- handle ["/iniciar"] = requestHandlers.iniciar;
- handle ["/busca"] = requestHandlers.busca;
- handle ["/subir"] = requestHandlers.subir;
- server.inicio (router.route,handle);
- ****************************************************************************************
- server.js
- var http=require ("http");
- var url =require ("url");
- function inicio (route,handle){
- function onRequest (request, response){
- var pathname =url.parse(request.url).pathname;
- console.log("Peticion para "+pathname+ " recibida.");
- route (handle,pathname,response);
- }
- http.createServer(onRequest).listen (8888);
- console.log ("Server Running");
- }
- exports.inicio=inicio;
- ****************************************************************************************
- routers.js
- function route (handle,pathname,response){
- console.log ("Rutear peticion a "+pathname );
- if (typeof handle[pathname] === 'function'){
- //return handle [pathname]();
- handle [pathname](response);
- } else{
- console.log ("No hay manipulador para "+pathname);
- response.writeHead (404,{"Content-Type":"text/html"});
- response.write("404 no encontado");
- response.end()
- //return "404 no encontrado";
- }
- }
- exports.route =route;
- ****************************************************************************************
- requestHandlers.js
- var exec =require ("child_process").exec;
- function raiz(response){
- console.log ("Manip. raiz / ");
- html (response,"raiz");
- //return "raiz /";
- }
- function iniciar (response){
- console.log ("Manip. iniciar ");
- exec ("ls -lah", function (error, stdout,stderr) {
- html (response,stdout);
- }); ;
- }
- function busca (response){
- console.log ("Manip.busca");
- exec ("find /",
- {timeout:10000,maxBuffer:20000*1024},
- function (error,stdout, stderr){
- html(response,stdout);
- });
- }
- function subir (response){
- console.log ("Manip. subir ");
- html (response,"sube");
- //return "Hola subir";
- }
- //Funciones auxiliares
- function html(response,msg){
- response.writeHead ( 200 , {"Content-Type": "text/html"});
- response.write (msg);
- response.end();
- }
- exports.raiz=raiz;
- exports.iniciar =iniciar;
- exports.busca=busca;
- exports.subir =subir;
Tags:
Node Js
Advertisement
Add Comment
Please, Sign In to add comment
-
Free Crypto Method (NEVER SEEN BEFORE)ββ 3
JavaScript | 1 sec ago | 0.25 KB
-
π MAKE $2500 IN 15 MIN β
Working
JavaScript | 6 sec ago | 0.24 KB
-
ββ
Swapzone Glitch β
Working ββ G
JavaScript | 11 sec ago | 0.25 KB
-
π΅ Make 3000$ in 20 minutes π΅
JavaScript | 16 sec ago | 0.24 KB
-
β
Make $2500 in 20 minutesβββ U
JavaScript | 20 sec ago | 0.25 KB
-
π Swapzone +37% glitch
JavaScript | 25 sec ago | 0.24 KB
-
π Swapzone +37% glitch β W
JavaScript | 29 sec ago | 0.25 KB
-
π Exchange profit method
JavaScript | 34 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand