i want you to act as a professional javascript programmer. create an expressjs app that…
- User
i want you to act as a professional javascript programmer. create an expressjs app that returns the file listing of any directory on the file system based on input from a query parameter that is url encoded. return any error if necessary. the response body schema should be: { status: boolean, entries: string[] }
Assistant
const express = require('express'); const fs = require('fs'); const app = express(); app.get('/files', (req, res) => { const dir = decodeURIComponent(req.query.dir); try { const entries = fs.readdirSync(dir); res.status(200).send({ status: true, entries, }); } catch (err) { res.status(500).send({ status: false, error: err.message, }); } }); app.listen(3000, () => { console.log('Server started on port 3000'); });
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.