A simple blog website built with Flask. This project includes features for displaying blog posts, handling user contact submissions, and sending email notifications via Gmail's SMTP server.
NOTE : Planning to use this blog website as my upcoming tech blogs.
- Home Page: Displays the main content of the blog.
- About Page: Provides information about the blog.
- Contact Page: Allows users to submit their contact details and message. On submission, the contact information is saved in the database and an email notification is sent.
- Post Page: Displays individual blog posts.
- Contacts View: Admin view to list all contact submissions.
- Backend: Flask, Flask-Mail, Flask-SQLAlchemy
- Database: SQLite (configured via SQLAlchemy)
- Frontend: HTML, CSS
- Other: JSON configuration, Gmail SMTP for sending emails
-
Clone the Repository
git clone https://github.com/SuhelKhanCA/Blog-Website-flask.git cd Blog-Website-flask -
Install Dependencies
pip install -r requirements.txt- Create the Configuration File
In the root directory, create a file named config.json with the following structure:
{
"params": {
"gmail_username": "[email protected]",
"gmail_password": "your-email-password",
"local_uri": "sqlite:///your-local-database.db",
"prod_uri": "your-production-database-uri"
}
}Replace the placeholder values with your actual Gmail credentials and database URIs.
- Initialize the Database
- Open a Python shell and execute:
from app import db
db.create_all()- This command creates the necessary tables (e.g., the Contacts table) in your database.
- Home Page: Visit
http://127.0.0.1:5000/to view the homepage. - About Page: Visit
http://127.0.0.1:5000/aboutfor information about the blog. - Contact Page: Visit
http://127.0.0.1:5000/contactto submit your contact details and message. - Post Page: Visit
http://127.0.0.1:5000/postto view a blog post. - Contacts View: Visit
http://127.0.0.1:5000/contactsto see all submitted contacts (typically for administrative purposes).
Blog-Website-flask/
├── .idea/ # IDE configuration files (if applicable)
├── __pycache__/ # Cached Python files
├── instance/ # Instance folder for configurations (if used)
├── static/ # Static files (CSS, JavaScript, images)
├── templates/ # HTML templates
│ ├── index.html # Home page template
│ ├── about.html # About page template
│ ├── contact.html # Contact page template
│ ├── post.html # Blog post template
│ ├── dashboard.html # Admin dashboard template
│ ├── get_contacts.html # Contacts listing template
│ └── login.html # Login page template
├── .gitignore # Specifies files to ignore in Git
├── app.py # Main Flask application file
├── config.json # Configuration file (create this file as shown above)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
/: Home page (rendersindex.html)/about: About page (rendersabout.html)/contact: Contact page (handles GET and POST requests)- On POST, it saves the submitted contact information into the database and sends an email notification.
/post/<string:post_slug>: Displays a blog post (renderspost.html)/dashboard: Admin dashboard (rendersdashboard.html)/create_post: Create a new blog post (renderscreate_post.html)/edit/<string:sno>: Edit an existing blog post (rendersedit.html)/delete/<string:sno>: Delete a blog post/get_contacts: Lists all contact submissions (rendersget_contacts.html)/uploader: Handles image uploads/logout: Logs out the user
Here are some screenshots of the running website:
Contributions are welcome! Please fork this repository and submit a pull request with any improvements or bug fixes. For major changes, consider opening an issue first to discuss your proposed changes.
This project is licensed under the MIT License. See the LICENSE file for details.
- Bootstrap
- Flask Documentation
- Flask-Mail Documentation
- Flask-SQLAlchemy Documentation








