You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You need to create an express HTTP server in Node.js which will handle the logic of a file server.
Use built in Node.js fs module
The expected API endpoints are defined below,
GET /files - Returns a list of files present in ./files/ directory
Response: 200 OK with an array of file names in JSON format.
Example: GET http://localhost:3000/files
GET /file/:filename - Returns content of given file by name
Description: Use the filename from the request path parameter to read the file from ./files/ directory
Response: 200 OK with the file content as the response body if found, or 404 Not Found if not found. Should return File not found as text if file is not found
Example: GET http://localhost:3000/file/example.txt
- For any other route not defined in the server return 404
The text was updated successfully, but these errors were encountered:
You need to create an express HTTP server in Node.js which will handle the logic of a file server.
Use built in Node.js
fs
moduleThe expected API endpoints are defined below,
./files/
directoryResponse: 200 OK with an array of file names in JSON format.
Example: GET http://localhost:3000/files
Description: Use the filename from the request path parameter to read the file from
./files/
directoryResponse: 200 OK with the file content as the response body if found, or 404 Not Found if not found. Should return
File not found
as text if file is not foundExample: GET http://localhost:3000/file/example.txt
- For any other route not defined in the server return 404
The text was updated successfully, but these errors were encountered: