You can fetch data from an external API and display it in Streamlit.
Example: Fetching Data from a Public API
python
Copy code
import streamlit as st import requests
# Fetch data from a sample API response = requests.get("https://jsonplaceholder.typicode.com/posts") data = response.json()st.title("Data from API") st.write("Here are the posts fetched from a sample API:")# Display the fetched data for item in data[:5]: # Display only the first 5 posts st.subheader(item['title']) st.write(item['body'])
46. Multi-Page Streamlit Application
You can create multi-page applications using the streamlit-multipage library or manually managing page navigation.
Example: Basic Multi-Page Setup
python
Copy code
import streamlit as st
# Sidebar navigation page = st.sidebar.selectbox("Select a page", ["Home", "Data", "About"])# Home Page if page == "Home": st.title("Welcome to the Home Page!")…