File size: 1,052 Bytes
23e4a5a
2b6a591
 
 
23e4a5a
 
2b6a591
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23e4a5a
 
 
 
 
2b6a591
 
23e4a5a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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.
    """
)