When you make contributions please test your code before sending a PR.
>>> python unit_test.py
Download and install Python, I am using Python 3.7.2, make sure to check the box Add Python to PATH on the installation setup screen.
Download and install MySQL Community Server and MySQL Workbench, you can skip this step if you already have a MySQL server set up.Major operations handled
1). Form Design — Design a login and registration form with HTML5 and CSS3.
2). Templates — Create Flask templates with HTML and Python.
3). Basic Validation — Validating form data that is sent to the server (username, password, and email).
4). Session Management — Initialize sessions and store retrieved database results.
5). MySQL Queries — Select and insert records from/in our database table.
6). Routes — Routing will allow us to point our URL's to our functions.
Download and install Python, for this tutorial I'll be using Python 3.7.2, make sure to check the box Add Python to PATH on the installation setup screen
Navigate to your current project directory for this case it will be Login-System-with-Python-Flask-and-MySQL.
git clone https://github.com/{your-Github-Username }/Login-System-with-Python-Flask-and-MySQL.git
Check to make sure you are in the same directory where you did the git clone,if not navigate to that specific directory.
Depending on your operating system,make a virtual environment to avoid messing with your machine's primary dependencies
Windows
cd Login-System-with-Python-Flask-and-MySQL
py -3 -m venv venv
macOS/Linux
cd Login-System-with-Python-Flask-and-MySQL
python3 -m venv venv
Windows
venv\Scripts\activate
macOS/Linux
. venv/bin/activate
or
source venv/bin/activate
Applies for windows/macOS/Linux
pip install -r requirements.txt
-- Create the database named "loginapp"
CREATE DATABASE loginapp;
-- Switch to 'loginapp' database;
USE loginapp;
-- Create 'account' table with id, username,email, password columns.
CREATE TABLE accounts (
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL
);
For linux and macOS Make the run file executable by running the code
chmod 777 run
Then start the application by executing the run file
./run
On windows
set FLASK_APP=main
flask run
Register Page:
Log In Page:
Home Page After Log In:
Note:-The version of python i use will change in future , so check your python IDE with latest version and if this doesn't work get in touch with me on twitter, https://twitter.com/HarunMbaabu.