Express.js app for image upload and gallery viewing, featuring single/multiple uploads, random image display, and pagination.
- Single image upload
- Multiple image upload
- View a single random image
- View multiple random images
- Gallery view
- Gallery pagination
- Node.js
- npm
-
Clone the repository:
git clone https://github.com/yourusername/your-repository.git cd your-repository
-
Install dependencies:
npm install multer express dotenv morgan
-
Create a
.env
file in the root directory and add your environment variables (if any). -
Ensure the following directory structure:
a2_n01598445/ ├── middlewares/ │ ├── errorHandler.js │ ├── fileStorage.js │ └── logger.js ├── node_modules/ ├── public/ │ ├── css/ │ │ └── styles.css ├── uploads/ ├── views/ │ ├── index.html │ ├── single.html │ ├── upload.html │ └── upload-multiple.html │ └── multiple-random.html ├── .env ├── .gitignore ├── index.js ├── package-lock.json └── package.json
-
Start the server:
node index.js
-
Open your browser and navigate to
http://localhost:3000
.
- URL:
/
- Method:
GET
- Description: Home page with links to all features.
- URL:
/upload
- Method:
GET
,POST
- Description: Upload a single image.
- URL:
/upload-multiple
- Method:
GET
,POST
- Description: Upload multiple images.
- URL:
/single
- Method:
GET
- Description: View a single random image.
- URL:
/multiple-random
- Method:
GET
- Description: View multiple random images based on user input.
- URL:
/gallery
- Method:
GET
- Description: View all uploaded images in a gallery format.
- URL:
/gallery-pagination
- Method:
GET
- Description: View paginated gallery images.