KOSUNI KOREA
Korean News in English
Technology

Building a Blog with Python: Writing Posts and Creating a List Feature

Published October 17, 2026 · 1 views
Building a Blog with Python: Writing Posts and Creating a List Feature

[Python 강좌] Python Flask 블로그 만들기, 지금부터 함께 시작합니다.


Let's Build a Real Blog

So far, our project has been a blog with only a visual interface.

It had menus and design but couldn't actually create or save posts.

This lesson finally implements the most important features of a blog: writing posts and displaying a list of them.

Once these features are complete, our simple webpage starts to resemble a functional blog.


How Does Writing Work?

Writing a post on a blog is simpler than you might think.

The user enters a title and content, Flask receives the data, and MySQL stores it.

Then, the stored data is retrieved and displayed in a list view.

We can summarize this flow as follows:

User Input
      │
      ▼
Flask Server
      │
      ▼
MySQL Storage
      │
      ▼
Display Post List

This is how most bulletin boards operate.


Creating the Writing Interface

First, we need a screen where users can input their posts.

Typically, this includes:

  • Title

  • Content

  • Submit button

We'll start with the basic structure and add features like image uploads in later lessons.


Transmitting Data via POST Method

To save a post, we use the POST method.

In HTML, this is written as:

<form method="post">
    ...
</form>

The POST method securely sends user input to the server.

It's commonly used for login, registration, and writing posts where sensitive data is involved.


Receiving Input in Flask

We retrieve the title and content from the user in Flask.

For example:

title = request.form["title"]
content = request.form["content"]

The request.form function fetches data from the HTML form.

Storing this data in MySQL completes the writing feature.


Saving Posts to MySQL

We store the input data into the database.

For instance, using SQL like:

INSERT INTO posts(title, content)
VALUES(%s, %s)

This saves a new post with the given title and content.

After saving, we call commit() to finalize the changes.


Retrieving Post Lists

Now, let's display the saved posts on screen.

First, query MySQL for the posts:

SELECT * FROM posts
ORDER BY id DESC;

This sorts posts in descending order by ID, so newer posts appear at the top.


Displaying Lists with Jinja2

After retrieving data, we display it on the HTML page.

In Jinja2, this is done using a loop:

{% for post in posts %}
<h2>{{ post.title }}</h2>
{% endfor %}

If multiple posts exist, the same HTML repeats for each entry.

This technique is widely used across boards, comments, and search results.


Watch Your Blog Grow

As you write more posts, they appear in the list one by one.

Each new post adds to the growing list.

Seeing your blog store and retrieve data makes web development feel rewarding—a moment many developers describe as their first big win.


Displaying More Details in the List

A list with just titles isn't very helpful. Including basic info improves usability:

  • Post ID

  • Title

  • Date posted

All this data comes directly from MySQL.

Adding these details makes the list look more like a real blog.


What's Still Missing?

We can now save and display posts, but some features are still missing:

  • No way to view full post content by clicking on it.

  • No option to edit or delete posts.

These will be covered in the next lesson.


Understanding the Basic Structure

The features we've built form the foundation of almost all bulletin boards:

Write Post
      │
      ▼
MySQL Storage
      │
      ▼
Retrieve and Display List

Mastering this structure allows you to build blogs, community boards, product reviews, or announcements.


Key Takeaways

The core concepts covered today include:

  • Input data via HTML forms

  • Send data to Flask using POST method

  • Store posts in MySQL through Flask

  • Retrieve data with SELECT queries

  • Display lists using Jinja2 loops

Understanding this flow gives you the foundation for most web applications that use databases.


Wrapping Up

This lesson implemented the core blog features: writing posts and displaying a list of them.

Our blog is now more than just a visual interface—it's a functional web application that stores and displays data.

In the next lesson, we'll add features to view full post content by clicking on it, along with edit and delete options. This will bring our blog closer to a fully working version.

FAQ

Why use POST instead of GET for form submissions?

POST securely sends data to the server without exposing it in the URL, making it suitable for sensitive information like posts or login details.

What is Jinja2 used for in this tutorial?

Jinja2 is a templating engine that dynamically generates HTML by looping through database records and displaying them on the page.

Korean Source

This article is an English localization of a Korean-language report from BlogScore. Original: [Python 강좌] 7강. 블로그 글 작성과 목록 기능 만들기