Hi guys welcome back to my blog therichpost.com. Guys today in this blog post I am going to Build a Complete Website Using Python and Flask (Beginner Friendly).
Guys python is one of the most in-demand programming languages today, and Flask is a lightweight yet powerful web framework that lets you build real websites quickly.
In this tutorial, you will learn how to build a complete multi-page website using Python and Flask, step by step. This guide is perfect for beginners and includes full working code.
What You Will Build
A complete website with:
- Home page
- About page
- Contact page (with form)
- CSS styling
- Python backend using Flask
Requirements
Before starting, make sure you have:
- Python 3.10 or higher installed
- Basic understanding of HTML (optional)
Check Python installation:
python --version
If Python is not installed, download it from the official Python website and make sure to check “Add Python to PATH” during installation.
Install Flask
Open terminal or command prompt and run:
pip install flask
If pip does not work:
py -m pip install flask
Project Folder Structure
Create a project folder like this:
python-website/
│
├── app.py
├── static/
│ └── style.css
│
└── templates/
├── base.html
├── home.html
├── about.html
└── contact.html
This structure is used in real-world Flask projects.
app.py (Main Python File)
This file controls routing and backend logic.
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route("/")
def home():
return render_template("home.html")
@app.route("/about")
def about():
return render_template("about.html")
@app.route("/contact", methods=["GET", "POST"])
def contact():
message = ""
if request.method == "POST":
name = request.form.get("name")
email = request.form.get("email")
message = f"Thanks {name}, we received your message!"
return render_template("contact.html", message=message)
if __name__ == "__main__":
app.run(debug=True)
base.html (Main Layout)
This file is shared by all pages.
<!DOCTYPE html>
<html>
<head>
<title>Python Flask Website</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<header>
<h1>🐍 Python Flask Website</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/contact">Contact</a>
</nav>
</header>
<div class="container">
{% block content %}{% endblock %}
</div>
<footer>
<p>© 2026 Python Website</p>
</footer>
</body>
</html>
home.html
{% extends "base.html" %}
{% block content %}
<h2>Welcome</h2>
<p>This is a complete website built using Python and Flask.</p>
<p>Fast, simple, and beginner-friendly.</p>
{% endblock %}
about.html
{% extends "base.html" %}
{% block content %}
<h2>About Us</h2>
<p>This project demonstrates how Python can be used for web development.</p>
{% endblock %}
contact.html
{% extends "base.html" %}
{% block content %}
<h2>Contact Us</h2>
<form method="POST">
<input type="text" name="name" placeholder="Your Name" required>
<input type="email" name="email" placeholder="Your Email" required>
<button type="submit">Send</button>
</form>
{% if message %}
<p class="success">{{ message }}</p>
{% endif %}
{% endblock %}
style.css
body {
font-family: Arial, sans-serif;
background: #f4f6f8;
margin: 0;
}
header {
background: #222;
color: #fff;
padding: 15px;
}
nav a {
color: #fff;
margin-right: 15px;
text-decoration: none;
}
.container {
padding: 20px;
}
footer {
background: #222;
color: #fff;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
input, button {
padding: 10px;
margin: 8px 0;
}
button {
background: #007bff;
color: white;
border: none;
cursor: pointer;
}
.success {
color: green;
}
Run the Website
Navigate to the project folder and run:
py app.py
Open your browser and visit:
http://127.0.0.1:5000
Final Result
You have successfully built a complete Python Flask website with multiple pages, styling, and form handling. Also if you will have any query then contact me via my contact us page above.
Ajay
Thanks
