Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,48 +1,35 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
# Title of the app
|
| 6 |
-
st.title("
|
| 7 |
-
|
| 8 |
-
# Input for the
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
plt.figure()
|
| 27 |
-
plt.plot(x, y, label=f'y = {function}')
|
| 28 |
-
plt.xlabel('x')
|
| 29 |
-
plt.ylabel('y')
|
| 30 |
-
plt.title('Plot of the function')
|
| 31 |
-
plt.legend()
|
| 32 |
-
plt.grid(True)
|
| 33 |
-
|
| 34 |
-
# Display the plot
|
| 35 |
-
st.pyplot(plt)
|
| 36 |
-
except Exception as e:
|
| 37 |
-
st.error(f"Error in plotting the function: {e}")
|
| 38 |
|
| 39 |
# Instructions for the user
|
| 40 |
st.sidebar.title("Instructions")
|
| 41 |
st.sidebar.info(
|
| 42 |
"""
|
| 43 |
-
Enter
|
| 44 |
-
|
| 45 |
-
Click the "Plot" button to visualize the function.
|
| 46 |
"""
|
| 47 |
)
|
| 48 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from io import BytesIO
|
| 5 |
|
| 6 |
# Title of the app
|
| 7 |
+
st.title("Profile Picture Generator")
|
| 8 |
+
|
| 9 |
+
# Input for the name
|
| 10 |
+
name = st.text_input("Enter your name:")
|
| 11 |
+
|
| 12 |
+
# Button to get the profile picture
|
| 13 |
+
if st.button("Get Profile Picture"):
|
| 14 |
+
if name:
|
| 15 |
+
# Generate URL for the profile picture
|
| 16 |
+
url = f"https://robohash.org/{name}.png"
|
| 17 |
+
|
| 18 |
+
# Fetch the image from the URL
|
| 19 |
+
response = requests.get(url)
|
| 20 |
+
if response.status_code == 200:
|
| 21 |
+
img = Image.open(BytesIO(response.content))
|
| 22 |
+
st.image(img, caption=f'Profile Picture for {name}', use_column_width=True)
|
| 23 |
+
else:
|
| 24 |
+
st.error("Error fetching the image. Please try again.")
|
| 25 |
+
else:
|
| 26 |
+
st.error("Please enter a name.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# Instructions for the user
|
| 29 |
st.sidebar.title("Instructions")
|
| 30 |
st.sidebar.info(
|
| 31 |
"""
|
| 32 |
+
1. Enter your name in the text input box.
|
| 33 |
+
2. Click the "Get Profile Picture" button to generate and view a profile picture associated with the entered name.
|
|
|
|
| 34 |
"""
|
| 35 |
)
|
|
|