Building a CMS for Flask with Streamlit
Tags:
python,
blogging,
streamlit,
web_dev
Date: 2025-03-12
The beauty of Flask lies in its simplicity, but the cost of this simplicity is the absence of tools that are present out-of-the-box in other more complete (and complex) frameworks. One of these is an admin panel for content management.
If you want to create a Content Management System (CMS) for your site similar to what WordPress offers, you can take several approaches. The first, which we reject outright due to its overly restrictive nature, is to use a pre-packaged solution. If you want to develop a solution tailored to your specific needs, you have two options: create a content management panel directly on the website (with related user and access management), or create a tool to run locally. The latter is the perfect solution to avoid complicating your life.
Streamlit is a Python library that allows you to easily create dashboards and web apps. The idea in this case is to create a portal to run locally, capable of connecting to the database containing your articles and allowing you to create or modify new content using a UI instead of relying on insert queries to the database.
The advantage of such a solution is the ability to model the web app exactly for your purposes. In my case, I needed a portal that would facilitate writing (or modifying) content in the dedicated articles table of the site, which has the following structure:
* id
* title
* slug
* date
* content
* tags
In my case, it made sense for the slug to be generated automatically, as well as the date. Currently I manage the content as regular HTML code, but for the future it might be useful to switch to markdown.
This approach combines the flexibility of Flask with the rapid development capabilities of Streamlit, giving you full control over your content without unnecessary complexity. The solution is lightweight, runs locally, and can be modified to suit your evolving needs as your blog grows.
Repository link: https://github.com/bianchimario/streamlitCMS