60 Frontend Vs Backend Vs Database
60 Frontend Vs Backend Vs Database
Frontend What the user sees and interacts with The HTML form you fill in your
browser
Backend Logic behind the scenes that processes The Flask app in Python that receives
user input form data
Databas Where data is stored permanently The MySQL table where user info is
e saved
2. When the form is submitted, it sends data to the backend (Flask)
3. The backend receives the data, processes it, and inserts it into the database (MySQL)
🧾 Real-Life Analogy:
Layer Real-World Example
The waiter doesn’t cook (frontend), the kitchen does (backend), and they keep a log of every
order (database).
🔥 Project: "Simple Web Form to Save Data"
✅ 1. Overview
Layer Tech Used Description
✅ 2. Prerequisites
● Python 3 installed
Install dependencies:
✅ 3. MySQL Setup
Login to MySQL and create database and table:
name VARCHAR(100),
email VARCHAR(100)
);
├── app.py
├── templates/
│ └── form.html
<!DOCTYPE html>
<html>
<head>
<title>User Form</title>
</head>
<body>
<label>Name:</label><br>
<label>Email:</label><br>
</form>
</body>
</html>
import pymysql
app = Flask(__name__)
# Connect to MySQL
db = pymysql.connect(
host="localhost",
@app.route('/')
def form():
return render_template('form.html')
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
email = request.form['email']
cursor = db.cursor()
db.commit()
if __name__ == '__main__':
app.run(debug=True)
✅ 7. How to Run the App
python app.py
Built a full-stack application that collects user input from an HTML form and stores
the data in a MySQL database using Python Flask. The backend handles traditional
POST requests and processes form data without REST API. Used PyMySQL for
database connection and routing with Jinja templates.