Python Flask Portfolio Website Project

Written by

in

Creating a Python Flask portfolio website is one of the most rewarding projects for both budding and experienced developers. Not only does it showcase your technical skills, it also provides a live, interactive résumé that can impress recruiters, clients, and peers. In this guide we’ll walk through every step of building a modern, responsive portfolio site with Flask—from project setup and routing to templating, styling, and deployment—so you can launch a polished showcase of your work in just a few hours.

Why Choose Flask for Your Portfolio?

Flask is a lightweight, micro‑framework that gives you full control over the structure of your application. Here are a few reasons why it’s ideal for a personal portfolio:

  • Flexibility: You decide how to organize files, routes, and templates without the constraints of a larger framework.
  • Fast development: Minimal boilerplate means you can focus on design and content.
  • Python ecosystem: Leverage powerful libraries for image handling, markdown rendering, or even a simple CMS.
  • Easy deployment: Flask apps run on virtually any hosting platform—Heroku, Render, Fly.io, or a traditional VPS.

Project Structure Overview

A clean file layout makes maintenance easier and improves SEO by keeping URLs tidy. Below is a recommended structure for a Flask portfolio project:

portfolio/
│
├── app/
│   ├── __init__.py          # Flask app factory
│   ├── routes.py            # View functions / routes
│   ├── models.py            # Optional (e.g., for blog posts)
│   ├── static/
│   │   ├── css/
│   │   │   └── style.css
│   │   ├── js/
│   │   │   └── main.js
│   │   └── images/
│   │       └── profile.jpg
│   └── templates/
│       ├── base.html
│       ├── index.html
│       ├── projects.html
│       └── contact.html
│
├── config.py                # Configuration settings
├── requirements.txt         # Python dependencies
└── run.py                    # Entry point for development server

Step‑By‑Step Guide to Building the Portfolio

1. Set Up the Development Environment

Start by creating a virtual environment and installing Flask:

python -m venv venv
source venv/bin/activate   # On Windows use `venv\Scripts\activate`
pip install Flask
pip freeze > requirements.txt

2. Create the Application Factory

Using an app factory keeps the codebase scalable and test‑friendly. In app/__init__.py:

from flask import Flask
from .routes import main

def create_app():
    app = Flask(__name__)
    app.register_blueprint(main)
    return app

3. Define Routes and Views

All public pages live in app/routes.py. A simple Blueprint example:

from flask import Blueprint, render_template

main = Blueprint('main', __name__)

@main.route('/')
def home():
    return render_template('index.html')

@main.route('/projects')
def projects():
    # In a real app you might load project data from a JSON file or DB
    projects = [
        {'title': 'E‑Commerce API', 'description': 'RESTful API built with Flask‑RESTful', 'link': '#'},
        {'title': 'Data Visualizer', 'description': 'Interactive charts using Plotly', 'link': '#'},
        # Add more projects here
    ]
    return render_template('projects.html', projects=projects)

@main.route('/contact')
def contact():
    return render_template('contact.html')

4. Build the Base Template

The base.html file contains the common HTML head, navigation, and footer. Use semantic tags and include meta data for SEO:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title|default('My Portfolio') }}</title>
    <meta name="description" content="Showcase of Python Flask projects, web development skills, and open‑source contributions.">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <header>
        <nav>
            <a href="{{ url_for('main.home') }}">Home</a>
            <a href="{{ url_for('main.projects') }}">Projects</a>
            <a href="{{ url_for('main.contact') }}">Contact</a>
        </nav>
    </header>

    <main>
        {% block content %}{% endblock %}
    </main>

    <footer>
        <p>© {{ current_year }} Your Name. All rights reserved.</p>
    </footer>
    <script src="{{ url_for('static', filename='js/main.js') }}"></script>
</body>
</html>

5. Design the Home Page

The home page introduces you and highlights key skills. Use headings, a hero image, and a concise bio.

{% extends "base.html" %}
{% block content %}
<section class="hero">
    <img src="{{ url_for('static', filename='images/profile.jpg') }}" alt="Your Name" class="profile-pic">
    <h2>Hi, I’m {{ your_name }}</h2>
    <p>Python developer | Flask enthusiast | Full‑stack web engineer</p>
    <a href="{{ url_for('main.projects') }}" class="btn">View My Projects</a>
</section>

<section class="skills">
    <h3>Core Skills</h3>
    <ul>
        <li>Python & Flask – REST APIs, templating, authentication</li>
        <li>HTML5 & CSS3 – Responsive design, Flexbox, Grid</li>
        <li>JavaScript – Vanilla JS, AJAX, front‑end interactivity</li>
        <li>Databases – SQLite, PostgreSQL, SQLAlchemy ORM</li>
    </ul>
</section>
{% endblock %}

6. Showcase Projects Dynamically

Loop through the projects list in projects.html. Each project card includes a title, short description, and a link to a live demo or GitHub repo.

{% extends "base.html" %}
{% block content %}
<section class="projects">
    <h2>My Projects</h2>
    <div class="grid">
        {% for project in projects %}
        <article class="card">
            <h3>{{ project.title }}</h3>
            <p>{{ project.description }}</p>
            <a href="{{ project.link }}" target="_blank" class="btn">Explore</a>
        </article>
        {% endfor %}
    </div>
</section>
{% endblock %}

7. Add a Contact Form (Optional)

While a simple mailto link works, integrating Flask‑Mail or a third‑party service (e.g., Formspree) gives a professional feel. Below is a minimal contact page using a static form that posts to a Flask route.

{% extends "base.html" %}
{% block content %}
<section class="contact">
    <h2>Get In Touch</h2>
    <form action="{{ url_for('main.send_message') }}" method="POST">
        <label for="name">Name</label>
        <input type="text" id="name" name="name" required>

        <label for="email">Email</label>
        <input type="email" id="email" name="email" required>

        <label for="message">Message</label>
        <textarea id="message" name="message" rows="5" required></textarea>

        <button type="submit" class="btn">Send</button>
    </form>
</section>
{% endblock %}

Styling for a Modern Look

Keep CSS in static/css/style.css. Below is a concise starter stylesheet that uses CSS variables, Flexbox, and a mobile‑first approach.

:root {
--primary: #2c3e50;
--accent: #e74c3c;
--bg: #f9f9f9;
--text: #333;
--radius: 8px;
--spacing: 1rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
font-family: '

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *