Da-Blairs / dashboard

Apache License 2.0
1 stars 0 forks source link

image #1

Open gavinblair opened 3 months ago

gavinblair commented 3 months ago
import streamlit as st
import schedule
import time
import requests
from PIL import Image
from io import BytesIO

# Create a Streamlit app
st.title("Image Updater")

# Create a container to hold the image
image_container = st.container()

# Function to update the image
def update_image():
    # Get the image from the URL
    url = "https://example.com/image.jpg"  # Replace with your image URL
    response = requests.get(url)
    image = Image.open(BytesIO(response.content))
    # Display the image in the container
    image_container.image(image, use_column_width=True)

# Schedule the image update every 5 seconds
schedule.every(5).seconds.do(update_image)

# Run the app
while True:
    update_image()
    time.sleep(1)
    schedule.run_pending()
    st.experimental_rerun()