A Flask blog application built with Bootstrap styling, rich-text posts, user authentication, and comments.
- Blog posts with create, read, update, and delete workflows
- User registration, login, and logout
- Password hashing with Werkzeug
- Rich text editing for posts and comments via CKEditor
- Comment system tied to authenticated users
- Admin-only post management (admin is the user with
id == 1) - SQLAlchemy models for posts, users, and comments
- Flask
- Bootstrap-Flask
- Flask-SQLAlchemy / SQLAlchemy 2
- Flask-Login
- Flask-WTF / WTForms
- Flask-CKEditor
- python-dotenv
Flask-Blog-Bootstrap/
├── main.py
├── forms.py
├── requirements.txt
├── blog_data.txt
├── instance/
├── static/
│ ├── assets/
│ ├── css/
│ └── js/
└── templates/
├── about.html
├── contact.html
├── footer.html
├── header.html
├── index.html
├── login.html
├── make-post.html
├── post.html
└── register.html
- Python 3.10+
- pip
git clone <your-repo-url>
cd Flask-Blog-BootstrapWindows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1Windows CMD:
python -m venv .venv
.venv\Scripts\activate.batmacOS/Linux:
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtSet at least these values before running the app:
FLASK_KEY(required)DB_URI(optional, defaults tosqlite:///posts.db)
Example:
FLASK_KEY=replace_with_a_long_random_secret
DB_URI=sqlite:///posts.dbNote: main.py currently calls load_dotenv("D:/API/EnvironmentVariables/.env"). If that file does not exist on your machine, define the variables in your shell or update this path.
python main.pyDefault URL:
The app creates database tables automatically on startup with db.create_all().
Userid,email,password,name- one-to-many with
BlogPost - one-to-many with
Comment
BlogPostid,title,subtitle,date,body,img_url,author_id- many-to-one with
User - one-to-many with
Comment
Commentid,text,author_id,post_id- many-to-one with
User - many-to-one with
BlogPost
GET /- List all postsGET|POST /register- Register a new userGET|POST /login- Log inGET /logout- Log outGET|POST /post/<int:post_id>- View a post and submit commentsGET|POST /new-post- Create a post (admin only)GET|POST /edit-post/<int:post_id>- Edit a post (admin only)GET /delete/<int:post_id>- Delete a post (admin only)GET /about- About pageGET /contact- Contact page
- Admin access is hard-coded to the first registered user (
current_user.id == 1). - The app currently runs with
debug=False. FLASK_KEYmust be set or form/session features may fail.
Reinstall dependencies:
pip install -r requirements.txtMake sure FLASK_KEY is set in your environment.
- Confirm
DB_URIpoints where you expect. - Restart the app to ensure tables are created.
MIT. See LICENSE.