import streamlit as st import requests from PIL import Image from io import BytesIO # Title of the app st.title("Profile Picture Generator") # Input for the name name = st.text_input("Enter your name:") # Button to get the profile picture if st.button("Get Profile Picture"): if name: # Generate URL for the profile picture url = f"https://robohash.org/{name}.png" # Fetch the image from the URL response = requests.get(url) if response.status_code == 200: img = Image.open(BytesIO(response.content)) st.image(img, caption=f'Profile Picture for {name}', use_column_width=True) else: st.error("Error fetching the image. Please try again.") else: st.error("Please enter a name.") # Instructions for the user st.sidebar.title("Instructions") st.sidebar.info( """ 1. Enter your name in the text input box. 2. Click the "Get Profile Picture" button to generate and view a profile picture associated with the entered name. """ )