A modern, feature-rich blog website built with Flask and Bootstrap. This web application allows users to read blog posts, register accounts, leave comments, and provides admin functionality for managing blog content.
- Blog Posts: Display and read blog posts with rich text content
- User Authentication: Secure user registration and login system
- Comment System: Registered users can leave comments on blog posts
- Admin Panel: Administrative users can create, edit, and delete blog posts
- Responsive Design: Modern, mobile-friendly interface using Bootstrap 5
- Password hashing with Werkzeug security
- User session management with Flask-Login
- Admin-only decorators for protected routes
- CSRF protection with Flask-WTF
- Clean, professional blog layout
- Rich text editor (CKEditor) for blog content and comments
- Gravatar integration for user profile images
- Modern CSS styling with custom themes
- Backend: Flask (Python web framework)
- Database: SQLAlchemy with SQLite (development) / PostgreSQL (production)
- Frontend: Bootstrap 5, HTML5, CSS3, JavaScript
- Authentication: Flask-Login
- Forms: WTForms with Flask-WTF
- Rich Text: CKEditor
- Deployment: Heroku-ready with Gunicorn
- Python 3.7 or higher
- pip (Python package manager)
-
Clone the repository
git clone https://github.com/Pranay-Dommati/MyBlogsWebsite.git cd MyBlogsWebsite-master
-
Create a virtual environment
python -m venv blog_env source blog_env/bin/activate # On Windows: blog_env\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set environment variables Create a
.env
file in the root directory:SECRET_KEY=your-secret-key-here DATABASE_URI=sqlite:///posts.db
-
Initialize the database
python main.py
The database will be automatically created on first run.
-
Access the application Open your browser and navigate to
http://localhost:5001
- Browse and read blog posts on the homepage
- View individual blog posts with full content
- Access About and Contact pages
- Register for an account using email and password
- Login to access additional features
- Leave comments on blog posts
- View and interact with other users' comments
The first registered user (ID: 1) automatically becomes the admin and can:
- Create new blog posts with rich text content
- Edit existing blog posts
- Delete blog posts
- Manage all site content
MyBlogsWebsite-master/
├── main.py # Main Flask application
├── forms.py # WTForms form definitions
├── requirements.txt # Python dependencies
├── Procfile # Heroku deployment configuration
├── static/ # Static assets
│ ├── assets/ # Images and icons
│ ├── css/ # Custom stylesheets
│ └── js/ # JavaScript files
└── templates/ # HTML templates
├── header.html # Navigation header
├── footer.html # Page footer
├── index.html # Homepage
├── post.html # Individual post view
├── make-post.html # Create/edit post form
├── login.html # Login page
├── register.html # Registration page
├── about.html # About page
└── contact.html # Contact page
id
: Primary keytitle
: Post title (unique)subtitle
: Post subtitledate
: Publication datebody
: Post content (rich text)img_url
: Featured image URLauthor_id
: Foreign key to Usercomments
: Relationship to Comment model
id
: Primary keyemail
: User email (unique)password
: Hashed passwordname
: Display nameposts
: Relationship to BlogPost modelcomments
: Relationship to Comment model
id
: Primary keytext
: Comment contentauthor_id
: Foreign key to Userpost_id
: Foreign key to BlogPost
Required environment variables for production:
SECRET_KEY
: Flask secret key for session managementDATABASE_URI
: Database connection string (PostgreSQL for Heroku)
- Modify
static/css/styles.css
for custom styling - Update background images in
static/assets/img/
- Customize the site title and subtitle in
templates/index.html
The application includes commented code for contact form email functionality. To enable:
- Uncomment the email-related code in
main.py
- Set up email environment variables
- Configure SMTP settings
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature
) - Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature/new-feature
) - Create a Pull Request
For questions, issues, or suggestions, please open an issue in the GitHub repository.