Skip to content

A step-by-step Flask weblog project built with SQLAlchemy, Flask-Migrate, and Bootstrap. Includes user authentication, email verification, role management, blogging, user following, and comments. (Ongoing development 🚧)

Notifications You must be signed in to change notification settings

fredsun02/flask-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flask Website

A professional Flask-based web project following Lanqiao's tutorial, implementing user authentication, database migrations, and more.

Flask Python Licence

Introduction

This project is a Flask-based web application. It aims to implement a fully functional website with user authentication, a blog system, and a clean UI using Flask-Bootstrap.

Features

  • User Authentication: Complete functionality for user registration, login, and logout.
  • Email Verification: Automatic email verification upon registration using Flask-Mail, including token generation and email templates.
  • Secure Password Hashing: Passwords are securely hashed using werkzeug.security to protect user credentials.
  • Database Management: Database migrations are handled by Flask-Migrate, allowing for seamless schema changes.
  • Role-Based Access Control: Implementation of user roles and permissions, ensuring that only authorised users can access specific features.
  • Dynamic User Profiles: Users can manage their profiles, including attributes such as age, gender, phone_number, location, and about_me.
  • User Activity Tracking: Tracks and displays the last seen time for users, enhancing user engagement.
  • Responsive User Interface: A clean and responsive user interface built with Flask-Bootstrap, ensuring a good user experience across devices.
  • Error Handling: Custom error pages for 404 and 500 errors to improve user experience.
  • Asynchronous Email Sending: Emails are dispatched in a separate thread to prevent blocking the main application thread.
  • Form Validation: Utilises Flask-WTF for form handling and validation, ensuring user input is properly checked.
  • Dynamic Time Formatting: Uses Flask-Moment for displaying and formatting dates and times dynamically.
  • Blog system with posts and comments (coming soon...)
  • User profile and settings (coming soon...)

Installation

1. Clone the Repository

git clone https://github.com/fredsun02/flask-website.git
cd flask-website

2. Create a Virtual Environment

python3 -m venv venv
source venv/bin/activate  # macOS/Linux
venv\Scripts\activate     # Windows

3. Install Dependencies

pip install -r requirements.txt

Usage

1. Set Up Environment Variables

Before running the application, export the necessary environment variables:

export FLASK_APP=manage.py
export FLASK_ENV=development
export FLASK_DEBUG=1

2. Initialise the Database

flask db init
flask db migrate -m "Initial migration"
flask db upgrade

3. Start the Application

flask run

Now open your browser and visit: http://127.0.0.1:5000


Project Structure

flask-website/
β”œβ”€β”€ README.md               # Project documentation
β”œβ”€β”€ log.md                 # Development logs
β”œβ”€β”€ manage.py              # CLI entry point
β”œβ”€β”€ migrations/            # Database migrations
β”œβ”€β”€ requirements.txt       # Dependencies
β”œβ”€β”€ scripts/              # Utility scripts
β”‚   └── generate_fake_data.py  # Test data generator
└── weblog/               # Main application package
    β”œβ”€β”€ handlers/         # View functions (blueprints)
    β”œβ”€β”€ templates/        # HTML templates
    β”œβ”€β”€ static/           # Static files (CSS, JS, etc.)
    β”œβ”€β”€ app.py            # Application factory
    β”œβ”€β”€ configs.py        # Configuration settings
    β”œβ”€β”€ decorators.py     # Custom decorators
    β”œβ”€β”€ email.py          # Email functionality
    β”œβ”€β”€ forms.py          # Form definitions
    └── models.py         # Database models

Licence

This project is licensed under the MIT Licence - see the LICENCE file for details.


Built with Flask and Love by fredsun02

About

A step-by-step Flask weblog project built with SQLAlchemy, Flask-Migrate, and Bootstrap. Includes user authentication, email verification, role management, blogging, user following, and comments. (Ongoing development 🚧)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published