Building a Multi-Page App with Streamlit ??

Building a Multi-Page App with Streamlit ??

Streamlit is a popular Python library for creating interactive web applications with minimal effort. In this article, I'll explore how to build a multi-page app using Streamlit, allowing users to navigate through different sections seamlessly.

?? ?? CLICK HERE TO WATCH VIDEO

Setting Up the App

To get started, make sure you have Streamlit installed. You can install it using

pip install streamlit        

Now, let's create a simple app with three pages: "Main Page," "Projects," and "Contact."

# Import Streamlit
import streamlit as st

# Set page configuration
st.set_page_config(
    page_title="Multipage App",
    page_icon="??",
)

# Main Page
st.title("Main Page")
st.sidebar.success("Select a page above.")

if "my_input" not in st.session_state:
    st.session_state["my_input"] = ""

my_input = st.text_input("Input a text here", st.session_state["my_input"])
submit = st.button("Submit")

if submit:
    st.session_state["my_input"] = my_input
    st.write("You have entered:", my_input)

# Projects Page
st.title("Projects")
st.write("You have entered:", st.session_state["my_input"])

# Contact Page
st.title("Contact")        

In the above code, we set up the Streamlit app with a title and configured page settings. The main page allows users to input text and submit it, while the "Projects" and "Contact" pages display the entered text.

Running the App

Save the script in a file, let's say multi_page_app.py, and run it using

streamlit run multi_page_app.py        

This will open a new tab in your browser with the Streamlit app.

Navigating Between Pages

The navigation is facilitated through the Streamlit sidebar. Users can select different pages from the sidebar to view relevant content.

.

.

  • Creating a multi-page app with Streamlit is straightforward, making it an excellent choice for rapid web application development. You can expand on this foundation by adding more pages and customizing the app to meet your specific requirements.


Thank You..!!! ??


Nethmi Nikeshala

Senior Engineer | UG | Junior Research fellow ??

1 年

Thanks for posting

回复

要查看或添加评论,请登录

Nethmi Nikeshala的更多文章

  • How do you view running processes using ps and top?

    How do you view running processes using ps and top?

    Okay, imagine you're the conductor of a busy orchestra. You need to keep track of all the musicians playing, what…

  • Docker RUN

    Docker RUN

    What is and Why Use It? Think of Docker containers like food delivery boxes. ?? The food (your application) is packed…

    2 条评论
  • The Happiest Animal on Earth

    The Happiest Animal on Earth

    In the vast tapestry of the animal kingdom, there exists a creature that wears a perpetual smile and radiates unbridled…

    1 条评论
  • How create AWS Instances ?

    How create AWS Instances ?

    ?? Welcome aboard our AWS Cloud journey, where we're about to take off into the skies of innovation and efficiency…

  • HAND TO BEGINNERS from KDS

    HAND TO BEGINNERS from KDS

    ____Your Beginner's Guide to JS on the Server____ . .

  • COFFEE SHOP for PEN TESTING

    COFFEE SHOP for PEN TESTING

    Imagine your favorite local coffee shop as a computer system. It has a network (Wi-Fi), servers (point-of-sale…

  • Test Automation in DevOps

    Test Automation in DevOps

    In the dynamic world of software development, teams are constantly striving to deliver high-quality products faster and…

  • BLOOMING SUCCESS

    BLOOMING SUCCESS

    "Understanding DevOps Pipelines through the Flower Shop Analogy" ( You can drop My Test Automation Article ) In the…

  • Test Automation in DevOps

    Test Automation in DevOps

    In the dynamic world of software development, teams are constantly striving to deliver high-quality products faster and…

社区洞察

其他会员也浏览了