Serve-RW is a lightweight file server that supports reading, writing, and deleting files via HTTP requests. It allows you to easily expose a directory over HTTP with MIME types, directory listings, and full CORS support. You can use PUT requests to upload or replace files and DELETE requests to remove them.
- Dynamic File Serving: Serve files with correct MIME types.
- Directory Listing: Auto-generates an HTML listing for directories.
- File Uploads: Upload or replace files via
PUTrequests. - File Deletion: Remove files using
DELETErequests. - CORS Enabled: Open to any origin, making it accessible for external resources.
- Command-Line Configurable: Easily configure the port and root directory.
- Error Handling: Errors are shown in HTML and logged to the console.
You can install serve-rw globally using npm:
npm install -g serve-rwAlternatively, you can clone the repository:
git clone https://github.com/n3rdyme/serve-rw.git
cd serve-rw
npm installOnce installed, you can run the server with:
serve-rw --port <port> --directory <path>--port <port>: Specify the port the server listens on (default:3000).--directory <path>: Set the root directory for serving files (default:./config).
Example:
serve-rw --port 8080 --directory /path/to/your/directoryAccess any file or directory via a GET request. If the path is a directory, an HTML page listing its contents will be returned.
Example:
curl http://localhost:8080/myfile.txtUse a PUT request to upload a new file or replace an existing one.
Example:
curl -X PUT --data-binary @yourfile.txt http://localhost:8080/uploadedfile.txtUse a DELETE request to remove a specific file.
Example:
curl -X DELETE http://localhost:8080/myfile.txtWhen a directory is requested, an HTML page with a listing of its contents will be returned. The page includes navigation links to subdirectories and a link to the parent directory (if applicable).
If an error occurs (e.g., a file is not found or the server encounters an issue), a user-friendly HTML error page will be returned, and the error will be logged to the console for easy debugging.
If you'd like to contribute:
- Fork the repository.
- Create your feature branch:
git checkout -b feature/my-new-feature
- Commit your changes:
git commit -am 'Add new feature' - Push the branch:
git push origin feature/my-new-feature
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Find this project on GitHub: n3rdyme/serve-rw
Now you can easily expose directories over HTTP with full read-write capabilities using serve-rw. Happy serving!