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

95
Views
renderizar página con archivos en respuesta express

desea enviar archivos desde el servidor para que se rendericen en el navegador en index pug

 extends layout block content h1= 'saved files' #recordings.recordings.row script(src='/javascripts/listrecordings.js')
 function fetchRecordings() { fetch('/') .then((response) => response.json()) .then((response) => { console.log("response " + response); if (response.success && response.files) { //remove all previous recordings shown recordingsContainer.innerHTML = ''; response.files.forEach((file) => { //create the recording element const recordingElement = createRecordingElement(file); //add it the the recordings container recordingsContainer.appendChild(recordingElement); }) } }) .catch((err) => console.error(err)); };

Y la parte del índice js:

 router.get('/', (req, res) => { let files = fs.readdirSync('./public/upploads'); console.log(__dirname + " files length " + files.length); files = files.filter((file) => { // check that the files are audio files const fileNameArr = file.split('.'); return fileNameArr[fileNameArr.length - 1] === 'mp3'; }).map((file) => `/${file}`); //res.json({ success: true, files }); res.render('index', files);// stuck here ??? });

cómo hacer esta parte para disparar la respuesta al índice

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que una mejor manera de hacerlo es devolver una serie de rutas de los archivos .mp3 , por ejemplo:

 ['upploads/a.mp3', 'upploads/b.mp3' ]

Y en el cliente solo falta cargar el audio usando la url:

http://localhost:3000/cargas/a.mp3

Para configurar su directorio público, lea estos documentos .

about 4 years ago · Juan Pablo Isaza Report
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!