Project 68 — Flask Authentication App
A professional Flask web application that implements user authentication, including registration, login, logout, and protected routes. Users can securely register with an email, password, and name. Authenticated users can access protected content and download files.
README GENERATED BY AI
Features
- User registration with hashed passwords
- Login and logout functionality
- Protected routes using Flask-Login
- SQLite database for user management
- File download for authenticated users
- Secure session management
Technology Stack
- Python 3
- Flask — Web framework
- Flask-Login — Session and user management
- SQLAlchemy — ORM for SQLite database
- Werkzeug — Password hashing and security
Installation
Clone the repository
bash
git clone https://github.com/mythreshnaveen-debug/100-Projects-in-Python.git
cd 100-Projects-in-Python
Create a virtual environment
bash
python -m venv venv
source venv/bin/activate # Linux / macOS
venv\Scripts\activate.bat # Windows
Install dependencies
bash
pip install flask flask_sqlalchemy flask_login werkzeug
Running the Application
bash
python app.py
Visit http://127.0.0.1:5000/ in your browser.
Routes
| Route | Methods | Description |
| ----------- | --------- | ---------------------------------- |
| / | GET | Home page |
| /register | GET, POST | Register a new user |
| /login | GET, POST | User login |
| /secrets | GET | Protected page (login required) |
| /logout | GET | Logout user |
| /download | GET | Download file from static/files/ |
Security
- Passwords are hashed using PBKDF2 SHA-256 with salt.
- Protected routes require login (
@login_required). - User sessions are securely managed with Flask-Login.
Project Structure
project/
│
├── app.py # Main Flask application
├── users.db # SQLite database (auto-generated)
├── templates/
│ ├── index.html # Home page
│ ├── register.html # Registration page
│ ├── login.html # Login page
│ └── secrets.html # Protected page
├── static/
│ └── files/
│ └── cheat_sheet.pdf # Downloadable file
└── README.md # Project documentation
Notes
- The database
users.dbis automatically created on first run. - The
SECRET_KEYis randomly generated; for production, use a fixed secret key in environment variables. - The project is designed for learning and can be extended with email verification, password reset, and deployment features.
Future Enhancements
- Email verification and password reset
- Environment variable configuration for security
- Deployment to cloud platforms (Heroku, Render)
- Unit testing for authentication flows