VOOZH about

URL: https://www.geeksforgeeks.org/python/single-page-portfolio-using-flask/

⇱ Single Page Portfolio using Flask - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Single Page Portfolio using Flask

Last Updated : 23 Jul, 2025

In this article, we’ll discuss how to create a single-page portfolio webpage using the Flask framework. This project demonstrates how to build an impressive portfolio to showcase your skills and experience to HR professionals, colleagues, or potential employers.

Key features of this portfolio are-

  1. Download CV button: allowing visitors to download your CV.
  2. Contact Me: its a form that sends messages directly to your Gmail account.

Prerequisites

Installation and Setting Up Flask

Create a project folder and then inside that folder create and activate a virtual environment to install flask and other necessary modules in it. Use these commands to create and activate a new virtual environment-

python -m venv venv
.venv\Scripts\activate

And after that install flask using this command-

pip install Flask

Create two folders- templates and static in our app folder. They both serve a specific purpose in flask-

  • static: Store images, CSS files, and other static assets here.
  • templates: Store HTML files (e.g., index.html) .

To know more about creating flask apps, refer to- Creating Flask Applicaions

File Structure

After completing the project, our file system should look like this-

👁 portfolio-filestructure
File structure

Creating HTML

Inside the templates folder create index.html file, it is the main page of the portfolio website, designed with Bootstrap to look great on any device.

Key Features:

  • Navbar: Easy navigation.
  • Carousel: Highlights your profile.
  • Sections: About, Education, Skills, and Contact form.

Code Breakdown:

  • Head Section: Sets up the page with meta tags for responsiveness and links to Bootstrap CSS for styling.
  • Body Sections:
    • Header: Shows a logo or image at the top.
    • Navbar: A green menu bar with links to Education, Skills, and Contact sections (collapsible on small screens).
    • Carousel: Displays a profile picture, name, job title, and a quote (can slide if more items are added).
    • About: Shares a short bio and personal details like age, email, and address.
    • Education: Lists your degree, school, and projects.
    • Skills: Shows your programming languages, tools, and tech skills.
    • Contact: Includes a form to send you messages and a button to download your CV, plus contact info.
  • Bootstrap JS: Added at the end to make interactive features (like the navbar toggle) work.

Below is the snapshot of the live index.html page.

👁 portfolio1
Index.html
👁 portfolio2
index.html

Creating app.py

The app.py file contains our main flask app. It connects the front-end with the back-end, handling tasks like displaying the portfolio and managing the contact form. This script makes the site dynamic and interactive by processing user input and sending emails.

Other than basic flask libraries, we are going to use these libraries in this project-

  • EmailMessage: A Python class from the email.message module used to create structured email messages with headers (e.g., To, From, Subject) and content.
  • smtplib: A Python library that enables sending emails via the Simple Mail Transfer Protocol (SMTP), connecting to email servers like Gmail’s.

Code Explanation:

  • Route for Home Page: The root route ("/") renders an HTML template (index.html) to display the main page.
  • Route to Send Email: The /sendemail/ route handles POST requests. It extracts form data (name, subject, email, message) and uses the SMTP protocol (with Gmail settings) to send an email containing this information.
  • SMTP Configuration and Email Sending: It sets up the SMTP server with Gmail credentials, creates an email message using EmailMessage, and attempts to send the message. Any errors during sending are caught and printed.
  • App Execution: Finally, the Flask app runs in debug mode when executed directly.

Note: Before running your code please set your Gmail to receive Incoming messages by your portfolio. You can go directly by clicking here, and turn it ON otherwise you will show an SMTP authentication error.

👁 Image
Browser Setting

Running The Application

To run the flask app, use this command in the terminal-

python app.py

This will start the flask app and then visit the development url- "http://127.0.0.1:5000" in a browser.

👁 portfolio-terminal
Terminal Outpur after running the app
Comment
Article Tags:
Article Tags: