Skip to content

Livingpr/Flask-Webpage

Repository files navigation

run_app

Flask Authentication System

A basic user authentication system using Flask, SQLAlchemy, and Flask-Login. This system allows users to register, log in, and log out securely. It also includes password hashing for security using Flask-Bcrypt.

Features

  • User Registration: Allows new users to register an account with a unique username and hashed password.
  • User Login: Users can log in with their username and password.
  • Authentication: Protects routes that require users to be logged in.
  • Flash Messages: Flash messages are displayed for user feedback (e.g., successful login, registration errors).
  • Password Hashing: Passwords are hashed for security using Flask-Bcrypt.
  • Session Management: Users can log in, stay authenticated during the session, and log out.

Technologies Used

  • Flask: A micro web framework for Python.
  • Flask-SQLAlchemy: ORM to handle the database.
  • Flask-Bcrypt: To hash passwords for security.
  • Flask-Login: User session management.
  • SQLite: Database used for storing user credentials.

Prerequisites

  • Python 3.7+
  • pip (Python package manager)

Installation

  1. Clone the repository:
  2. git clone https://github.com/your-username/flask-authentication-system.git
    cd flask-authentication-system
    <li>Create a virtual environment and activate it:</li>
    <pre><code>python -m venv venv
    

    source venv/bin/activate # For Windows use: venv\Scripts\activate

    <li>Install the required packages:</li>
    <pre><code>pip install -r requirements.txt</code></pre>
    
    <li>Initialize the database:</li>
    <pre><code>python
    

    >>> from backend import db >>> db.create_all() >>> exit()

    <li>Run the Flask application:</li>
    <pre><code>python backend.py</code></pre>
    
    <li>Visit <a href="http://127.0.0.1:5000/">http://127.0.0.1:5000/</a> in your browser to see the application in action.</li>
    

Project Structure

flask-authentication-system/
│
├── backend.py          # Main Flask application
├── templates/          # HTML templates for rendering the pages
│   ├── login.html
│   ├── register.html
│   └── home.html
├── static/             # Static files (CSS, JS, images)
├── database.db         # SQLite database (created after running the app)
├── README.md           # Project documentation
└── requirements.txt    # Python dependencies

Routes

  • /register: Register a new account.
  • /: Login to an existing account.
  • /home: User's homepage (requires login).
  • /logout: Logout from the current session.

Flash Messages

Flash messages are used throughout the application to provide feedback to the user. They display messages like successful login, incorrect password, or registration errors.

Example Flash Messages

  • Success: Green flash message for actions like successful registration or login.
  • Error: Red flash message for failed actions like login failure or duplicate registration.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

flask framework webpage using python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors