This is a simple web application that allows users to create and share text snippets (pastes). When a user submits text, the application generates a unique random URL where the content can be viewed. The data is stored in memory and expires after 24 hours.
- Create text pastes.
- Generate a unique, random URL for each paste.
- View pastes at their unique URL.
- "Copy URL" button to easily share the link.
- Pastes automatically expire after 24 hours.
- In-memory storage, no database required.
- Dockerized for easy deployment.
- Backend: Node.js, Express.js
- Template Engine: EJS (Embedded JavaScript)
- Containerization: Docker
/
├── Dockerfile
├── index.js
├── package.json
├── package-lock.json
├── public/
│ └── css/
│ └── style.css
└── views/
├── index.ejs
├── notfound.ejs
└── paste.ejs
-
Clone the repository (or set up the files as done previously).
-
Install dependencies:
npm install
-
Start the server:
npm start
-
Open your browser and navigate to
http://localhost:3000.
You can either build the Docker image from the source or pull the pre-built image from Docker Hub.
-
Build the Docker image:
docker build -t pastebin-app . -
Run the Docker container:
docker run -d -p 3000:3000 --name pastebin-container pastebin-app
The image is publicly available on Docker Hub.
-
Pull the image: You can pull either a specific version or the latest one.
# Pull version 1 docker pull jgkong/pastebin-app:1 # Or pull the latest version docker pull jgkong/pastebin-app:latest
-
Run the Docker container:
docker run -d -p 3000:3000 --name pastebin-container jgkong/pastebin-app:1
After running the container, the application will be accessible at http://localhost:3000.
GET /: Displays the main page to create a new paste.POST /: Creates a new paste, saves it, and redirects to the new paste's URL.GET /:id: Displays the content of the paste with the corresponding ID.