Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
Cómo hacer que aparezcan directorios y archivos en el servidor, node.js

Tengo un código, muestra carpetas, puedo navegar por ellas y archivos también, pero esto solo funciona en la consola:

`

 const fs = require('fs/promises'); const fsToRead = require('fs') const path = require('path'); const inquirer = require('inquirer'); const yargs = require('yargs'); const { lstatSync, readdirSync } = require('fs'); const http = require('http'); const url = require('url'); const options = yargs .options('p', { describe: 'Pattern', default: '' }) .options('d', { describe: 'Path to directory', default: process.cwd() }).argv; console.log(options); class itemsList { constructor(path, fileName) { this.path = path; this.fileName = fileName; } get folders() { return lstatSync(this.path).isDirectory(); } } let executionDir = process.cwd(); const start = async () => { const list = await fs.readdir(executionDir); const items = list.map(fileName => new itemsList(path.join(executionDir, fileName), fileName)); const item = await inquirer.prompt([ { name: 'fileName', type: 'list', message: `Choose: ${executionDir}`, choices: items.map(item => ({name: item.fileName, value: item})), } ]).then(answer => answer.fileName); if (item.folders) { executionDir = item.path; return await start(); } else { const data = await fs.readFile(item.path, 'utf-8'); if (!options.p) { console.log(data) } else { const regExp = new RegExp(options.p, 'igm'); console.log(data.match(regExp)); } } } start();

`

COMO IMPLEMENTAR QUE MUESTRA EN LA PAGINA DEL NAVEGADOR, QUE EN LA VERSION WEB PUEDO IR A LAS CARPETAS, SI ESTO ES UN ARCHIVO MOSTRARA SU CÓDIGO, NO LO PASARÍA!

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!