[Python] Ikea Name Generator

IKEA Name Generator

IKEA name generator is a simple web app that converts your name into Swedish furniture (language).

It’s designed to be a simple demo of a streamlit app deployed on Heroku. Check it out on Heroku Check it out on Github

How it works

Building a simple web app is extremely simple with Streamlit. So simple that app.py can be condensed into only 3 lines of code, which is very impressive because you can’t even do that in 3 files in other python alternatives like Flask and Django.

Check it out:

import streamlit as st
from ikea_name_generator import gen_ikea_name

st.write("""
# IKEA Name Generator
Discover your name had you been born a piece of Swedish furniture.
""")

user_input = st.text_input("Enter your name") 

st.write(f"""
## Your IKEA name is...
# {gen_ikea_name(user_input)}
""")

app.py

To break it down further,

  • st.write() writes markdown to the website.
  • st.text_input() creates a text box object and the response can be stored to a variable.
  • Then the variable is passed into another st.write() method which displays the processed input to the app.

It’s not technically 3 lines because I imported the gen_ikea_name function as a module, but Streamlit is still super impressive.

To run a Streamlit application, all you have to do is execute streamlit run {APP NAME} in the command line and it will start up a local server.

Streamlit lets you deploy 2 Streamlit applications on their website for free, but I want to save my free deployments for something a little more useful, so I quickly deployed it for free on Heroku.

To do that, I just added a setup shell script to create a config.toml file and a Procfile, which is required by Heroku to know what to run to set up the web application.

That’s it!

Streamlit is a great way to quickly add a front end to a python process.

Keep in mind, one limitation that I’ve noticed is it’s not possible to do some asynchronous processes (such as changing the options for one drop down based on the status of another drop down or checkbox). It’s still a very good alternative for creating demos or MVPs when compared to actual web frameworks like Flask and Django, which have more features but are significantly more complex (given how simple Streamlit is).