Build a Student Attendance System with Flask and WeChat MiniProgram – Step‑by‑Step Guide

This tutorial walks you through creating a student attendance management system that combines a Flask backend with a WeChat MiniProgram frontend, covering project structure, database setup, virtual environment creation, API configuration, and deployment for both server and mobile client.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Build a Student Attendance System with Flask and WeChat MiniProgram – Step‑by‑Step Guide

1. Introduction

This project is a school attendance and course management application built with a WeChat MiniProgram frontend and a Python Flask backend. It integrates database management, API development, and front‑back communication to provide student attendance recording, schedule management, and teacher interaction features.

WeChat MiniProgram support: native syntax for convenient mobile access.

Flask backend: robust Python framework with multiple API endpoints.

Multiple modules: attendance records, schedule management, teacher publishing and review.

Database integration: remote MySQL for secure and efficient data storage.

Continuous updates: version iteration adds features, optimizes performance, and fixes bugs.

2. Project Structure

student_attendance_system
├── MiniProgram
│   ├── app.js               # MiniProgram main script
│   ├── app.json              # Global configuration
│   ├── app.wxss              # Global stylesheet
│   ├── components            # Component directory
│   │   └── …
│   ├── pages                # Page directory
│   │   └── …
│   ├── img                  # Image resources
│   │   ├── loginbg.jpg
│   │   └── …
│   ├── project.config.json   # Project config
│   └── utils                # Utility files
├── app.py                    # Main Flask application
├── datasets
│   ├── save_table.py         # Script to save tables
│   └── 学生考勤系统数据库用例表.xlsx
├── docs
│   ├── API
│   ├── QuickStart.md
│   ├── README.md
│   ├── _sidebar.md
│   ├── index.html
│   ├── 系统实现.docx
│   ├── 需求分析.docx
│   ├── 代码规范.md
│   ├── 数据库设计.docx
│   ├── 系统设计(UML与设计模式).docx
│   ├── 系统安全性问题.docx
│   └── 项目特色与创新点.docx
├── ds_tools
│   └── data_structure.py
├── models
│   ├── attendence_information_table.py
│   ├── class_schedule_table.py
│   ├── course_selection_table.py
│   ├── course_table.py
│   ├── post_attendance_table.py
│   ├── student_information_table.py
│   └── teacher_information_table.py
├── requirements.txt
├── routes
│   ├── __init__.py
│   ├── student_routes.py
│   └── teacher_routes.py
├── sql
│   ├── create_procedure.sql
│   ├── create_table.sql
│   ├── create_trigger.sql
│   ├── create_view.sql
│   └── init
│       ├── attendance_information.sql
│       ├── class_schedule.sql
│       ├── course.sql
│       ├── course_selection.sql
│       ├── post_attendance_information.sql
│       ├── student_information.sql
│       └── teacher_information.sql
├── student_attendance_system.drawio
├── test
│   ├── test_student_routes.py
│   └── test_teacher_routes.py
└── utils
    └── database_manager.py

3. Quick Start

3.1 Backend Flask Deployment

Required tools:

MySQL 8.3.0

conda environment

A database management tool (e.g., Navicat)

After installing the tools, follow these steps:

3.1.1 Import Database Quickly

Open Navicat, create a new local database (recommended name: StudentAttendanceSystemDB).

Right‑click the database, choose “Run SQL File”, and execute all .sql files in sql/init.

Database import step 1
Database import step 1
Database import step 2
Database import step 2

3.1.2 Create Virtual Environment

In the terminal:

conda create -name Flask python=3.8
conda activate Flask

Install dependencies:

conda install --file requirements.txt
mamba install --file requirements.txt

3.1.3 Modify Database Connection

Edit utils/database_manager.py and adjust the parameters db_user, db_password, db_host, and db_name to match your MySQL setup.

def __init__(self, table_name, db_user='your_user', db_password='your_password', db_host='127.0.0.1', db_port=3306, db_name='StudentAttendanceSystemDB'):
    self.db_user = db_user
    self.db_password = db_password
    self.db_host = db_host
    self.db_port = db_port
    self.db_name = db_name
    self.table_name = table_name
    self.engine = create_engine(self._get_connection_string())
    self.df = None

3.1.4 Start the Backend

Run the Flask app: python app.py You should see output indicating the server is running on http://0.0.0.0:5000.

3.2 Frontend MiniProgram Deployment

3.2.1 Register and Install Tools

Register a WeChat MiniProgram to obtain an AppID (optional; a test account can be used).

Download and install the WeChat MiniProgram Developer Tool.

Log in with WeChat QR code, create a new project, and import the MiniProgram folder.

3.2.2 Import Project

Open the developer tool, choose the MiniProgram directory, and set the AppID (or use a test ID).

3.2.3 Test Login

Enter test account 2021611011 on the home page.

Enter test name “张三”.

Click login and verify the result; consult API documentation if errors occur.

MiniProgram login screen
MiniProgram login screen
MiniProgram after login
MiniProgram after login

3.3 Testing the API

Use pytest to run route tests: pytest test/test_student_routes.py All tests should pass, confirming that the student and teacher routes work correctly.

(Flask) hiddensharp429@ZixiandeMBP Student Attendance System % pytest test/test_student_routes.py
... (output truncated) ...
7 passed, 6 warnings in 0.28s
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DeploymentmysqlFlaskWeChat MiniProgramStudent Attendance
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.