Welcome to the Node.js Playground! This project demonstrates the creation of a simple Node.js server that listens for requests and responds accordingly. The server can read content from a file, write and append content to it, providing a basic introduction to file manipulation with Node.js.
- Node.js Server: Simple server setup using Node.js.
- Read File Content: Handles requests to
/read
to read the content of a file (data.txt
) and displays it in the browser. - Write and Append Content: Handles requests to write and append content to a file (
writedata.txt
).
- Node.js
- HTTP Requests
- File Manipulation
- app.js: Contains the main logic for handling server requests.
- data.txt: Sample file for reading content.
- writedata.txt: File for writing and appending content.
- index.js: Entry point for the Node.js application.
- package.json: Project configuration file.
- package-lock.json: Lock file for Node.js dependencies.
-
Clone the repository:
git clone https://github.com/walidbosso/Nodejs_playground.git
-
Navigate to the project directory:
cd Nodejs_playground
-
Install dependencies:
npm install
-
Run the Node.js server:
node index.js
-
Open your browser and navigate to
http://localhost:3000/read
to read the content ofdata.txt
. -
To write and append content, make a POST request to
http://localhost:3000/write
with the desired content in the request body.
This project is licensed under the [Your License Name] License - see the LICENSE file for details.
If you'd like to contribute to the project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.
If you encounter any issues or have suggestions, please open an issue on the Issues page.
Thank you for exploring the Node.js Playground! 🚀