Skip to content

Create an express HTTP server in Node.js #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shash369 opened this issue May 7, 2025 · 0 comments
Open

Create an express HTTP server in Node.js #1

shash369 opened this issue May 7, 2025 · 0 comments
Labels

Comments

@shash369
Copy link
Member

shash369 commented May 7, 2025

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
@shash369 shash369 added the easy label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant