Building Python Scripts to speed up your tasks or automate tasks is fun & there are IDEs like Replit that kind of act like an App however they aren’t exactly apps.
What if I told you there is a way to transform your Python Code into a functional App that has a proper User Interface which will visualize the output in an intuitive way?
And the best part is that it is free!
Step 1: Transform your Python Code with Streamlit Import & some UI Aspects
Some of the code elements that the transformed Python Code would need are
import streamlit as st
This line of code imports streamlit which is where we want to create the app.
st.title('Google Search Console (GSC) Queries Race Chart')
st.title is the syntax that you use to display the title of your app.
st.plotly_chart(fig, use_container_width=True)
Since I was creating an app that visualizes Plotly data that is why you would see st.plotly.
In a nutshell, this is the kind of code modification that you will need to make.
Pro tip: Here is the ChatGPT prompt that can transform your existing Python Code with Streamlit elements
I have this python script that creates race chart visualization on GSC queries
here is the code
(paste the code here)
Transform this code in a way that I can turn this into Streamlit app; so the transformed code I will put on Github & connect streamlit via Github link & then I would like to see the visualization on Streamlit with play, pause button on Streamlit i should have option to upload csv file after which visualization should result
Step 2: Create your requirements.txt File
streamlit>=1.7.1
pandas>=1.4.0
plotly>=5.5.0
Here is an example of my requirements.txt file. This is what Streamlit is going to read to install the requirements.
Step 3: Move the Modified Python Code & Requirements.txt in GitHub
![python code on github](https://www.decodedigitalmarket.com/wp-content/uploads/2024/03/python-code-on-github-1024x445.png)
Here in the above screenshot you can see how I have moved my Python Code & requirements.txt file into GitHub Repository.
You will have to create a GitHub Repository first & then move these two files there by manually creating it.
For the Python Code file it should end with .py that’s the file extension and the requirements file should end with .txt
Step 4: Go to Streamlit.io > Create App > GitHub Option
![streamlit step 1](https://www.decodedigitalmarket.com/wp-content/uploads/2024/03/streamlit-step-1-1024x255.png)
As a first step click on “New App“
![streamlit app step 2](https://www.decodedigitalmarket.com/wp-content/uploads/2024/03/streamlit-app-step-2-1024x702.png)
Step 5: Paste GitHub .py File URL, Name the App & Hit Deploy
![Deploy-an-app-·-Streamlit](https://www.decodedigitalmarket.com/wp-content/uploads/2024/03/Deploy-an-app-·-Streamlit-1024x582.png)
Once you deploy your app you will be able to see it as a functional app. Sharing an example of my app below.
Here is an example of an app that I built whose backend GitHub code is Python. You have to upload a csv file containing following columns. In fact you can use my app here itself in this page as I have embedded this.
- query
- date
- clicks
Based on that you will get Race Chart Visualization Here based on dates. You will be able to see Query trends across the date range.
![kunjal chawhan](https://www.decodedigitalmarket.com/wp-content/uploads/2021/04/uyeejxhp4pe2fl0xicuh.jpg)
Kunjal Chawhan founder of Decode Digital Market, a Digital Marketer by profession, and a Digital Marketing Niche Blogger by passion, here to share my knowledge