- Introduction
- Prerequisites
- Installation
- Usage
- Project Structure
- Code Analysis
- License
The Flask Attendance App is a web-based application designed for marking attendance. This documentation provides an overview of the app's functionality, prerequisites for usage, installation instructions, and usage guidelines.
Before using the Flask Attendance App, ensure you have the following prerequisites installed:
- Python 3.x
- Flask
- Pandas
- gspread
- Google Sheets API credentials (JSON file)
- uuid
- os
Follow these steps to install and set up the Flask Attendance App:
-
Install the required dependencies:
pip install flask pandas gspreadpip install subprocess -
Set up Google Sheets API credentials:
- Create a Google Cloud project.
- Enable the Google Sheets API for your project.
- Generate API credentials in JSON format and save them to a file (e.g.,
credentials.json). - Place the
credentials.jsonfile in the project directory.
To use the Flask Attendance App, follow these steps:
-
Start the Flask app:
python app.py -
Open a web browser and navigate to http://localhost:5000/.
-
On the homepage, you'll see a form that requires you to enter your name and email address.
-
Fill in your name and email address.
-
Click the "Submit" button to mark your attendance.
-
The app will verify your credentials, including your email, MAC address, and Wi-Fi network name.
-
Depending on the time of day and verification results, you'll receive one of the following messages:
- "Already Marked": If you have already marked your attendance for the day.
- "Unmarked": If it's the right time to mark attendance and your credentials are valid.
- "Time over": If it's past the attendance marking time.
- "Window will open at 9 am": If it's not yet time to mark attendance.
The Flask Attendance App project is structured as follows:
- app.py: The main Flask application that handles routes and views.
- static: Directory containing static assets such as CSS files.
- templates: Directory containing HTML templates used by the app.
- email.xlsx: An Excel file used for storing email-related data.
- credentials.json: JSON file containing Google Sheets API credentials (not included in the repository).
-
Imports: The code begins by importing various Python modules and libraries, including Flask, subprocess, uuid, json, ast, datetime, gspread, pandas, os, and signal. These modules are used for various purposes in the application.
-
Flask App Setup: An instance of the Flask web application is created with
app = Flask(__name__). -
Functions for Gathering System Information:
get_connected_wifi_name(): This function uses thesubprocessmodule to obtain the name of the currently connected Wi-Fi network.get_mac_address(): This function retrieves the MAC address of the system.
-
Open URL in Browser: The code opens a web browser to the URL "http://127.0.0.1:5000/".
-
Routes and Views:
- The
/and/homeroutes are defined, and thehome()function is associated with them. This function renders the "index.html" template. - The
/resultroute is defined for handling form submissions. Theresult()function handles form data, checks the email against credentials, and marks attendance accordingly.
- The
-
Google Sheets Integration: The code interacts with Google Sheets to mark attendance and verify credentials. It uses the
gspreadlibrary to connect to a Google Sheets document named "attendance." -
Credential Verification and Attendance Marking:
get_cred(Email): Retrieves user credentials (Name, Batch, MAC, WiFi) based on their email.verf_cred(Email): Verifies user credentials by comparing the system's MAC address and Wi-Fi network name with the stored values.mark_attd(Email, name, batch): Marks attendance in the Google Sheets document if credentials are verified.
This project is licensed under the MIT License. See the LICENSE file for details.
With this documentation, users and contributors will have a clear understanding of your Flask Attendance App, its requirements, and how to use it.