A clean and user-friendly blog web application built with Flask. It supports user authentication, admin-protected blog post management, rich text content editing, and commenting. The backend uses PostgreSQL and is optimized for deployment on Render.com.
You can visit the live deployed application here: https://shubham-flask-blog.onrender.com/
- User registration and secure login with hashed passwords (PBKDF2 SHA-256)
- Admin-only access to create, edit, and delete blog posts
- Rich text editing for blog content via CKEditor integration
- Commenting system for authenticated users
- User avatars via Gravatar
- Responsive interface powered by Bootstrap 5
- Easy switch between SQLite (local dev) and PostgreSQL (production)
- Secure environment variable management for secrets and database URLs
- Python 3.12
- Flask 2.2.x framework
- Flask-Login for user session management
- Flask-WTF & WTForms for forms and validation
- Flask-CKEditor for rich text editing
- Flask-Bootstrap 5 for responsive UI
- SQLAlchemy ORM with PostgreSQL (psycopg driver)
- Render.com for cloud hosting and managed PostgreSQL
- Gunicorn as the production WSGI server
-
Clone the repository:
git clone https://github.com/shubhamjaju03/flask-blog.git cd flask-blog -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate
-
Install Python dependencies:
pip install -r requirements.txt
-
Set up environment variables:
SECRET_KEYfor Flask session securityDB_URIfor PostgreSQL connection string (use internal Render URL when deployed)
-
Initialize the database schema:
flask shell >>> from main import db >>> db.create_all() >>> exit()
-
Run the app locally:
flask run
- Provision a PostgreSQL instance on Render.
- Supply
DB_URIwith the internal database URL for low latency. - Set the Flask
SECRET_KEYsecurely in Render environment variables. - Deploy the app with Gunicorn.
- Monitor logs and environment variables via the Render dashboard.
- Register and login users.
- Admin user (default user ID 1) can manage blog posts.
- Authenticated users can comment on posts.
- Blog posts support title, subtitle, image URL, and formatted content.
- Comments display user avatars using Gravatar.
main.py— primary Flask app and route definitionsforms.py— form classes using Flask-WTFtemplates/— Jinja2 templates for rendering HTMLstatic/— stylesheets, images, and JavaScript assetsrequirements.txt— pinned Python dependencies
- Admin restriction is based on user ID 1 by default; customize as necessary.
- Passwords are securely hashed with salt and multiple iterations.
- The app gracefully supports local SQLite and PostgreSQL backends.
- Use Render’s internal Postgres URL for best performance and security.
This project is licensed under the MIT License.