A small Flask web application with user sign-up, login and logout, where each signed-in user can add and delete their own text notes. Data is stored in a local SQLite database.
- Sign up with email, first name and password (with confirmation)
- Log in and log out (sessions handled by Flask-Login, "remember me" enabled)
- Passwords are stored only as salted hashes (Werkzeug
generate_password_hash), never in plain text - Basic validation on sign-up: email of at least 4 characters, first name of at least 2 characters, matching passwords, password of at least 7 characters, and no duplicate emails
- Notes page (login required): add notes and delete your own notes
- Flash messages for success and error feedback
- Python 3.9+
- Flask
- Flask-SQLAlchemy (SQLite)
- Flask-Login
- Jinja2 templates, Bootstrap 4 (loaded from a CDN) and a small amount of JavaScript
git clone https://github.com/digantadatta/Login-System-Using-Flask.git
cd Login-System-Using-Flask
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate
pip install -r requirements.txtThe app reads these environment variables:
| Variable | Purpose | Default |
|---|---|---|
SECRET_KEY |
Signs session cookies. Set this to a long random value in production. | An insecure development key (a warning is logged) |
FLASK_DEBUG |
Set to 1 to run with the Flask debugger and reloader (development only) |
Off |
Generate a secret key with:
python -c "import secrets; print(secrets.token_hex(32))"# macOS/Linux
SECRET_KEY=your-secret FLASK_DEBUG=1 python main.py
# Windows PowerShell
$env:SECRET_KEY = "your-secret"; $env:FLASK_DEBUG = "1"; python main.pyThen open http://127.0.0.1:5000/ . On first start the SQLite database is created at website/database.db.
.
├── main.py # Entry point (python main.py)
├── requirements.txt # Python dependencies
├── website/
│ ├── __init__.py # Application factory, config, database creation
│ ├── auth.py # /login, /logout, /sign-up routes
│ ├── views.py # / (notes page) and /delete-note routes
│ ├── models.py # User and Note models
│ ├── static/index.js # Client-side note deletion
│ └── templates/ # base, home, login and sign_up templates
├── LICENSE
└── .github/workflows/ci.yml # CI: compile, flake8, smoke test
- Open
/sign-up, enter an email, first name and a password of at least 7 characters, and submit. You are signed in and taken to the notes page. - Type a note in the text area and press Add Note. It appears in the list.
- Click the
xnext to a note to delete it. - Use Logout in the navigation bar; log back in later from
/login.
This is a learning project. Before exposing it publicly, consider adding CSRF protection (for example Flask-WTF), rate limiting on login, and serving it with a production WSGI server rather than python main.py.
Released under the MIT License.
