Skip to content

Latest commit

 

History

History
85 lines (57 loc) · 1.58 KB

readme.md

File metadata and controls

85 lines (57 loc) · 1.58 KB

Flask Blog

A simple blog application built with Flask, SQLAlchemy, and Flask-WTF. Users can register, log in, create posts, comment, and edit or delete posts (admin only). This project demonstrates the use of Flask, database integration, user authentication, and forms.


Features

User Functionality

  • Register and log in
  • Add comments to posts
  • View all posts

Admin Functionality

  • Add new blog posts
  • Edit or delete posts

Blog Functionality

  • Display posts with title, subtitle, body, and image
  • Comment system
  • CKEditor for rich text in posts

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/flask-blog.git
cd flask-blog
  1. Create a virtual environment:
python -m venv .venv
# Linux / Mac
source .venv/bin/activate
# Windows
.venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Add environment variables in a .env file:
FLASK_KEY=your-secret-key
DB_URI=sqlite:///posts.db   # Optional: defaults to SQLite if not set

Usage

Run the application:

python main.py
  • Open your browser at http://127.0.0.1:5000/
  • Register a user or log in
  • Admin user (ID=1) can add, edit, or delete posts

Database

  • Uses SQLite by default (posts.db)
  • SQLAlchemy handles the database models: User, BlogPost, Comment

Notes

  • Keep your SECRET_KEY private
  • Admin-only routes are protected by a decorator
  • Uses Flask-Bootstrap5 and Flask-CKEditor for styling and rich text