Build a Website in 12 Minutes With Python and Streamlit
A personal website built in Streamlit: page config, a header, an about section, a Lottie animation, a project list, a working contact form and a custom theme. The layout is all Python; the only HTML and CSS is the small contact form. The whole build takes about twelve minutes.
Table of contents

Page configuration
Start with st.set_page_config, which sets the browser tab title and icon. layout="wide" lets the content use the full browser width instead of a narrow centered column. It must be the first Streamlit call in the script.
import streamlit as st
# Find more emojis here: https://www.webfx.com/tools/emoji-cheat-sheet/
st.set_page_config(page_title="My Webpage", page_icon=":tada:", layout="wide")
Header
The header is a short block at the top: a greeting, a title that says who you are, one sentence on what you do and a link to your main site. Each part is one Streamlit text call inside a container.
# ---- HEADER SECTION ----
with st.container():
st.subheader("Hi, I am Sven :wave:")
st.title("A Data Analyst From Germany")
st.write("I am passionate about finding ways to use Python and VBA to be more efficient and effective in business settings.")
st.write("[Learn More >](https://pythonandvba.com)")
About section
The “What I do” section splits the page into two columns: text about you on the left, and an empty right column that gets an animation in the next step. st.columns(2) creates the two equal columns.
# ---- WHAT I DO ----
with st.container():
st.write("---")
left_column, right_column = st.columns(2)
with left_column:
st.header("What I do")
st.write("##")
st.write(
"""
On my YouTube channel I am creating tutorials for people who:
- are looking for a way to leverage the power of Python in their day-to-day work.
- are struggling with repetitive tasks in Excel and are looking for a way to use Python and VBA.
- want to learn Data Analysis & Data Science to perform meaningful and impactful analyses.
- are working with Excel and found themselves thinking - "there has to be a better way."
If this sounds interesting to you, consider subscribing and turning on the notifications, so you don't miss any content.
"""
)
st.write("[YouTube Channel >](https://youtube.com/c/CodingIsFun)")
Lottie animation
A Lottie animation fills the empty right column of the What I do section. Install the component with pip install streamlit-lottie requests, add the imports and a small helper at the top of the script, then call st_lottie in the right column.
import requests
import streamlit as st
from streamlit_lottie import st_lottie
def load_lottieurl(url):
r = requests.get(url)
if r.status_code != 200:
return None
return r.json()
# ---- LOAD ASSETS ----
lottie_coding = load_lottieurl("https://assets5.lottiefiles.com/packages/lf20_fcfjwiyb.json")
# ---- WHAT I DO ----
with st.container():
st.write("---")
left_column, right_column = st.columns(2)
with left_column:
... # the What I do text from the previous step
with right_column:
st_lottie(lottie_coding, height=300, key="coding")
The full Lottie setup, including where to find animations, is covered in adding Lottie animations to Streamlit.
Projects
Each project is a row with an image on the left and a title, a short description and a link on the right. Load the images once with Pillow at the top of the script, then repeat the same container pattern per project.
from PIL import Image
# ---- LOAD ASSETS ----
img_contact_form = Image.open("images/yt_contact_form.png")
img_lottie_animation = Image.open("images/yt_lottie_animation.png")
# ---- PROJECTS ----
with st.container():
st.write("---")
st.header("My Projects")
st.write("##")
image_column, text_column = st.columns((1, 2))
with image_column:
st.image(img_lottie_animation)
with text_column:
st.subheader("Integrate Lottie Animations Inside Your Streamlit App")
st.write(
"""
Learn how to use Lottie Files in Streamlit!
Animations make our web app more engaging and fun, and Lottie Files are the easiest way to do it!
In this tutorial, I'll show you exactly how to do it
"""
)
st.markdown("[Watch Video...](https://youtu.be/TXSOitGoINE)")
with st.container():
image_column, text_column = st.columns((1, 2))
with image_column:
st.image(img_contact_form)
with text_column:
st.subheader("How To Add A Contact Form To Your Streamlit App")
st.write(
"""
Want to add a contact form to your Streamlit website?
In this video, I'm going to show you how to implement a contact form in your Streamlit app using the free service 'Form Submit'.
"""
)
st.markdown("[Watch Video...](https://youtu.be/FOULV9Xij_8)")
Contact form
Streamlit has no form-to-email feature, so the form is plain HTML that posts to the free FormSubmit service, which forwards each message to your inbox. Replace YOUR@MAIL.COM with your own address; the first submission asks you to confirm it.
# ---- CONTACT ----
with st.container():
st.write("---")
st.header("Get In Touch With Me!")
st.write("##")
# Documention: https://formsubmit.co/ !!! CHANGE EMAIL ADDRESS !!!
contact_form = """
<form action="https://formsubmit.co/YOUR@MAIL.COM" method="POST">
<input type="hidden" name="_captcha" value="false">
<input type="text" name="name" placeholder="Your name" required>
<input type="email" name="email" placeholder="Your email" required>
<textarea name="message" placeholder="Your message here" required></textarea>
<button type="submit">Send</button>
</form>
"""
left_column, right_column = st.columns(2)
with left_column:
st.markdown(contact_form, unsafe_allow_html=True)
with right_column:
st.empty()
Unstyled HTML inputs look out of place, so the repository loads a small stylesheet from style/style.css. Add this helper near the top of the script:
# Use local CSS
def local_css(file_name):
with open(file_name) as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
local_css("style/style.css")
And this is the stylesheet, based on a W3Schools contact form snippet. The last three rules hide Streamlit’s menu, footer and header.
/* Style inputs with type="text", select elements and textareas */
input[type=message], input[type=email], input[type=text], textarea {
width: 100%; /* Full width */
padding: 12px; /* Some padding */
border: 1px solid #ccc; /* Gray border */
border-radius: 4px; /* Rounded borders */
box-sizing: border-box; /* Make sure that padding and width stays in place */
margin-top: 6px; /* Add a top margin */
margin-bottom: 16px; /* Bottom margin */
resize: vertical /* Allow the user to vertically resize the textarea (not horizontally) */
}
/* Style the submit button with a specific background color etc */
button[type=submit] {
background-color: #04AA6D;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
/* When moving the mouse over the submit button, add a darker green color */
button[type=submit]:hover {
background-color: #45a049;
}
/* Hide Streamlit Branding */
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
If you want the messages to land in Google Sheets or your inbox without extra code, a webhook to a no-code tool does that.
Theme
Colors and the font come from a config file. Create a folder named .streamlit next to your script and put a config.toml file in it. Its [theme] section sets the colors and the font for the whole app.
[theme]
# Primary accent for interactive elements
primaryColor = '#7792E3'
# Background color for the main content area
backgroundColor = '#273346'
# Background color for sidebar and most interactive widgets
secondaryBackgroundColor = '#B9F1C0'
# Color used for almost all text
textColor = '#FFFFFF'
# Font family for all text in the app, except code blocks
# Accepted values (serif | sans serif | monospace)
# Default: "sans serif"
font = "sans serif"
For anything the theme settings cannot reach, use custom CSS in Streamlit. To put the finished site online, follow building and deploying a website in 7 minutes.
