Skip to content

MPALONDON/Flask-SQLAlchemy-Blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A website where users can post, edit and comment on blogs. also has simple user authentication. uses SQLAlchemy sqlite for database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors