DEV Community

Cover image for How I Built a Viral Post Generator using Python & Streamlit (Open Source-ish)
Muhammad Aqib
Muhammad Aqib

Posted on

How I Built a Viral Post Generator using Python & Streamlit (Open Source-ish)

Hi everyone! πŸ‘‹

I've been learning Python and wanted to move away from simple console scripts to building real web apps.

I decided to build a tool to solve my own problem: Writer's Block.

I built ViralBot, a Streamlit app that takes a topic (like "Coding" or "SaaS") and generates viral hooks using proven copywriting frameworks (Contrarian, Storytelling, etc.).

πŸ› οΈ The Tech Stack
Language: Python 3.9

Frontend: Streamlit

Logic: String formatting & Template lists

πŸ’‘ How it works
The app uses a dictionary of templates. When the user selects a "Vibe" (e.g., Contrarian), the Python script maps the user's topic into specific slots in the sentences.

Here is a snippet of the logic:

Python

templates_contrarian = [
"Stop doing {topic} the hard way.",
"Unpopular Opinion: Most advice about {topic} is wrong.",
"Why 99% of people fail at {topic}."
]

When user clicks generate:

for temp in selected_templates:
print(temp.format(topic=user_topic))
It’s simple, but it works incredibly well for generating LinkedIn and Twitter content fast.

πŸš€ Try it out
I deployed the app live on Streamlit Cloud. πŸ‘‰ Link to Live App

πŸ“¦ Want the Source Code?
I decided to package up the full project code, including:

The full viral_bot.py script.

The complete database of 50+ viral hooks.

White Label Rights: You can take this code, rebrand it, and sell it to your own clients as a micro-SaaS.

I'm selling the "Starter Kit" for just $9 (the price of a fancy coffee).

⚑ Download the Source Code here

Let me know what you think of the code structure in the comments!

Top comments (1)

Collapse
 
muhammad_aqib_421d83f63e2 profile image
Muhammad Aqib