<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anoop Johny</title>
    <description>The latest articles on DEV Community by Anoop Johny (@firefly248).</description>
    <link>https://dev.to/firefly248</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2803620%2Fdbfeeaee-a613-42b9-96b7-a3576bc7ec4c.png</url>
      <title>DEV Community: Anoop Johny</title>
      <link>https://dev.to/firefly248</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/firefly248"/>
    <language>en</language>
    <item>
      <title>Get Started With Streamlit</title>
      <dc:creator>Anoop Johny</dc:creator>
      <pubDate>Sun, 02 Feb 2025 06:07:35 +0000</pubDate>
      <link>https://dev.to/firefly248/get-started-with-streamlit-1jjn</link>
      <guid>https://dev.to/firefly248/get-started-with-streamlit-1jjn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Python frameworks such as Streamlit enable beginners and newbies to build and deploy highly interactive web applications spanning fields such as Data Science and Machine Learning. Creating Web applications has never been easier when beginners are not required to have front-end development experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
Ensure Python is installed on your system before proceeding with the installation of "Streamlit". To do so execute the following in the command line terminal.&lt;br&gt;
&lt;code&gt;python -h&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now once you have confirmed Python is installed execute this command using PIP to install the streamlit python package.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0s9u31suk0c8v9mof1j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0s9u31suk0c8v9mof1j.png" alt="Installation of Streamlit Python Framework to your local workspace using the PIP command" width="315" height="37"&gt;&lt;/a&gt;&lt;br&gt;
To verify the installation of Streamlit run :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this has been executed a new window should open up in your browser on the local port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Local URL: http://localhost:8501
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is your default Streamlit application running on port 8501 once successful installation has been achieved.&lt;/p&gt;

&lt;p&gt;Now let's create your first streamlit app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your First Streamlit App&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create any new python file with a name ,eg., app.py.&lt;/li&gt;
&lt;li&gt;Lets import the Streamlit Library&amp;gt;&amp;gt;
&lt;code&gt;
Import streamlit as st 
&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Name a title and welcome message text to your app.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;st.title("My App")
st.write("Welcome to my Streamlit Application")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now run the streamlit app by executing the command&amp;gt;&amp;gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upon execution the default browser should open your app on the port 8501 and you should see your message:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5xkbnhpm7mwfkfz62bds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5xkbnhpm7mwfkfz62bds.png" alt="Streamlit My App window opens on port 8501 on execution of command 'streamlit run app.py'" width="468" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some key features&lt;/strong&gt;&lt;br&gt;
Streamlit allows users to build several interactive widgets which enable building dynamic applications. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8uc1l9w5uelcavywtrlf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8uc1l9w5uelcavywtrlf.png" alt="Widgets are crucial for building dynamic web applications" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some of these widgets are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Text Input
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = st.text_input("Enter your name:")
st.write(f"Hello, {name}!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Slider Input
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;number = st.slider("Select a number", 0, 100, 50)
st.write(f"You selected: {number}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Button
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if st.button("Click Me"):
    st.write("Button clicked!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Data Use cases&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Streamlit allows to make depictions of tabular data in chart formats&amp;gt;&amp;gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DataFrame Display:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd

df = pd.DataFrame({
    "Column 1": [10, 20, 30, 40],
    "Column 2": [50, 60, 70, 80]
})
st.dataframe(df)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a basic data frame and it would show up as &amp;gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13jdwdhc5y3ahjmh2cku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13jdwdhc5y3ahjmh2cku.png" alt="A basic dataframe in streamlit" width="293" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Charts:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
y = np.sin(x)

fig, ax = plt.subplots()
ax.plot(x, y)
st.pyplot(fig)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A basic sine wave with X and Y co-ordinates is created in the app &amp;gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz3s34cfsd9hhqeowm0td.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz3s34cfsd9hhqeowm0td.png" alt="Sine wave chart in streamlit" width="800" height="563"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A sidebar can be added for better UI organization :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sidebar
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;st.sidebar.header("Sidebar Header")
option = st.sidebar.selectbox("Choose an option:", ["Option 1", "Option 2"])
st.sidebar.write(f"You selected: {option}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Side bars are great for managing several different tabs for a large application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deployment of Streamlit Apps&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once your app is completed, you can deploy it using:&lt;/p&gt;

&lt;p&gt;Streamlit Community Cloud (free hosting for Streamlit apps)&lt;/p&gt;

&lt;p&gt;Heroku, AWS, or Google Cloud&lt;/p&gt;

&lt;p&gt;For deployment into the Streamlit Cloud, push your code to GitHub and link it to Streamlit Cloud.&lt;/p&gt;

&lt;p&gt;read more about &lt;a href="https://docs.streamlit.io/" rel="noopener noreferrer"&gt;streamlit docs&lt;/a&gt; here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Streamlit is a potent tool for easy development of interactive web apps for data science and machine learning. The elegantly simple syntax and rich feature set make it an ideal choice for all developers and data scientists who wish to quickly convert their ideas into real-life applications.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>streamlit</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
