This is a simple blog application built with Express.js that allows users to create, read, update, and delete posts.
- View all posts
- Create a new post
- View a single post
- Edit a post
- Clone the repository:
git clone https://github.com/yourusername/express-blog.git
cd express-blog- Install dependencies:
npm install- Start the server:
node index.jsThe application will be running on http://localhost:8080.
Navigate to http://localhost:8080/posts to view all posts.
- Go to
http://localhost:8080/posts/new. - Fill in the form with your username and content.
- Submit the form to create a new post.
Click on a post from the list of all posts to view the details of that post.
- Click on the "Edit" button on the post details page.
- Update the content in the form.
- Submit the form to save the changes.
(Note: The delete functionality can be added similarly to the edit functionality, though it is not currently implemented in this code.)
express-blog/
│
├── index.js # Main server file
├── package.json # Project dependencies
├── views/ # EJS templates
│ ├── index.ejs # View for displaying all posts
│ ├── form.ejs # View for creating a new post
│ ├── show.ejs # View for displaying a single post
│ └── edit.ejs # View for editing a post
└── public/ # Static files (CSS, images, etc.)
- express: Fast, unopinionated, minimalist web framework for Node.js
- method-override: Allows the use of HTTP verbs such as PUT or DELETE in places where the client doesn't support it
- ejs: Embedded JavaScript templating
- uuid: Simple, fast generation of RFC4122 UUIDS
express.urlencoded({ extended: true }): Middleware for parsing URL-encoded bodiesmethod-override('_method'): Middleware for overriding HTTP methods
This project is licensed under the MIT License - see the LICENSE file for details.
This `README.md` file provides an overview of the application, installation instructions, usage guidelines, project structure, and dependencies. You can customize it further based on your specific requirements or preferences.