GitHunt
DE

Devyanikatta11/Flask_Calculator

A secure and modular Flask web application featuring JWT authentication, MySQL integration, and a user-friendly calculator interface. Ideal for learning full-stack development with Python.

Flask JWT Authentication App

A simple Flask application with user authentication using JWT (JSON Web Tokens) and MySQL for data storage.


๐Ÿ”ง Features

  • User registration and login
  • JWT-based authentication
  • MySQL database integration
  • Password hashing (using Werkzeug)
  • Utility functions (utils.py)
  • Environment-safe configuration

๐Ÿ—๏ธ Project Structure

/project-root
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ /templates
โ”‚ โ”œโ”€โ”€ index.html
โ”‚ โ”œโ”€โ”€ login.html
โ”‚ โ””โ”€โ”€ dashboard.html
โ”œโ”€โ”€ /static
โ”‚ โ””โ”€โ”€ cal.jpg (optional)
โ””โ”€โ”€ /Project
โ””โ”€โ”€ utils.py


๐Ÿš€ Getting Started

1. Clone the repository**

git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name

python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

4. Set up configuration

Create a .env file in the project root directory to store environment variables (do not commit this file to version control).

Example .env:
env
Copy
Edit
JWT_SECRET_KEY=your-secret-key
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASSWORD="yourpassword"
MYSQL_DB=mydatabase
โš ๏ธ Note: If your password contains special characters (like #, !, or spaces), wrap it in double quotes.

This .env file is loaded automatically by the app using python-dotenv.

5. Set up the database

Using MySQL CLI or GUI

source path/to/database.sql

6. Run the app

python app.py

๐Ÿ“ซ API Endpoints (example)

Method Route Description
POST /register User registration
POST /login User login
GET /protected JWT-protected endpoint

โš ๏ธ Make sure to include the JWT token in the Authorization: Bearer header for protected routes.