Python Flask Tutorial Medium Step by Step Guide for Web Development

Logan Jul 13, 2026

Python and Flask are a powerful combination for building web applications, and this guide will walk you through creating a simple and engaging blog platform using Python, Flask, and Medium's API. By the end of this tutorial, you'll have a comprehensive understanding of Flask web development and how to integrate a Medium API to import and display blog posts.

Flask Cheatsheet
Flask Cheatsheet

Before we dive in, ensure you have Python (3.8 or later) and pip installed on your system. Additionally, you'll need a virtual environment to set up and manage your project's dependencies. If you haven't already, install virtualenv by running pip install virtualenv in your terminal.

Learning python(Flask)
Learning python(Flask)

Setting Up the Flask Application

Start by creating a new directory for your project and entering it in your terminal. Next, create a new virtual environment and activate it:

Flask | Key features of Flask
Flask | Key features of Flask

On Windows:

python -m venv flask_medium_blog
flask_medium_blog\Scripts\activate

On macOS/Linux:

Learn Flask [2026] Most Recommended Tutorials
Learn Flask [2026] Most Recommended Tutorials

python3 -m venv flask_medium_blog
source flask_medium_blog/bin/activate

Now, install Flask if you haven't already:

pip install Flask

Create a new file named app.py and add the following basic Flask application structure:

Creating Routing in Flask

Create one executable file for a Flask app with PyInstaller
Create one executable file for a Flask app with PyInstaller

In Flask, routing maps URL paths to the associated functions. Let's set up simple routing for our blog platform:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def home():
    return "Welcome to our blog!"

@app.route('/about')
def about():
    return "This is our about page."

if __name__ == '__main__':
    app.run(debug=True)

Running the Flask Application

To run your application, simply execute python app.py in your terminal. You should see output indicating that your app is running on . Visit that URL in your browser, and you should see "Welcome to our blog!".

How to build a web app using Python’s Flask and Google App Engine
How to build a web app using Python’s Flask and Google App Engine

Now that we have the basic structure of our Flask application, let's move on to integrating the Medium API to fetch blog posts.

Integrating Medium API

Building Your First Website With Flask — Part 1
Building Your First Website With Flask — Part 1
Python Flask Tutorial 5 - Database with Flask-SQLAlchemy
Python Flask Tutorial 5 - Database with Flask-SQLAlchemy
Python Flask Cheat Sheet
Python Flask Cheat Sheet
Python Flask TODO App: Build a Web App with SQLite from Scratch
Python Flask TODO App: Build a Web App with SQLite from Scratch
Python Flask Tutorial 7 - Building Flask CRUD Application | CRUD Operations (Part 1 of 2)
Python Flask Tutorial 7 - Building Flask CRUD Application | CRUD Operations (Part 1 of 2)
How to use Python and Flask to build a web app — an in-depth tutorial
How to use Python and Flask to build a web app — an in-depth tutorial
Building My Portfolio Website Using Python Flask
Building My Portfolio Website Using Python Flask
Permute in Python (Explanation With Examples)
Permute in Python (Explanation With Examples)
Best Udemy Courses For Flask
Best Udemy Courses For Flask
Learn Python Online (2022): 22 Best Python Courses and Tutorials For Beginners
Learn Python Online (2022): 22 Best Python Courses and Tutorials For Beginners
Practical Python Projects
Practical Python Projects
Python Random Method
Python Random Method
| Pythonista Planet
| Pythonista Planet
Python Projects for Beginners: Top 10 Python Project Ideas in 2020
Python Projects for Beginners: Top 10 Python Project Ideas in 2020
a flow chart with instructions to learn how to use the python exercise for beginners
a flow chart with instructions to learn how to use the python exercise for beginners
Python Tkinter Project Ideas
Python Tkinter Project Ideas
FromTimeStamp Python Function with Examples
FromTimeStamp Python Function with Examples
a book cover with the title'basic guide to python sytax '
a book cover with the title'basic guide to python sytax '
Python Next Function (With Examples)
Python Next Function (With Examples)
Python Tutorial With Flet: Task + Management Application
Python Tutorial With Flet: Task + Management Application

First, sign up for a Medium account if you haven't already. Then, go to your profile page () and click on "Chevron down" icon next to "_edit profile and privacy" to access your profile settings. In the left-hand menu, select "API access".

Under "Medium API", click on the "Create API access token" button. Save this token as an environment variable in your virtual environment for secure storage. In a terminal, you can set it using export MEDIUM_API_TOKEN=your_token_here.

Fetching Blog Posts from Medium

To fetch blog posts from Medium, you'll need to use their GraphQL API. Install the gql library for simple and efficient usage of the GraphQL API:

pip install gql

Create a new file named medium.py and import the required libraries. Write a function that fetches blog posts using the Medium API:

Displaying Blog Posts on the Index Page

Now that we can fetch blog posts, let's display them on the index page of our blog platform:

In your app.py file, import the fetch_medium_posts function and the required libraries. Update the home function to fetch and display blog posts:

from flask import Flask, render_template
from medium import fetch_medium_posts

app = Flask(__name__)

@app.route('/')
def home():
    posts = fetch_medium_posts()
    return render_template('index.html', posts=posts)

Create a new folder named templates, and inside it, create a new file named index.html. Add the following HTML to display the fetched blog posts:

With this setup, your Flask application should now fetch and display your Medium blog posts. To truly bring your blog to life, you can style the index.html file and add functionality to create, update, and delete posts.

Keep exploring and expanding on this foundation, and you'll soon have a powerful and engaging blog platform built with Python and Flask. Happy coding!