whitphx HF staff commited on
Commit
759c4c4
1 Parent(s): e470fe2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import time
3
+ import streamlit as st
4
+ import numpy as np
5
+
6
+
7
+ st.title("Streamlit App at Hugging Face Spaces!")
8
+ st.image("https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png")
9
+
10
+ with st.form("my_form"):
11
+ st.write("Inside the form")
12
+ slider_val = st.slider("Form slider")
13
+ checkbox_val = st.checkbox("Form checkbox")
14
+
15
+ # Every form must have a submit button.
16
+ submitted = st.form_submit_button("Submit")
17
+ if submitted:
18
+ st.write("slider", slider_val, "checkbox", checkbox_val)
19
+
20
+ col1, col2, col3 = st.columns(3)
21
+
22
+ with col1:
23
+ st.image("https://static.streamlit.io/examples/cat.jpg")
24
+
25
+ with col2:
26
+ st.image("https://static.streamlit.io/examples/dog.jpg")
27
+
28
+ with col3:
29
+ st.image("https://static.streamlit.io/examples/owl.jpg")
30
+
31
+ with st.sidebar:
32
+ # st.image("https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png")
33
+ st.image("https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png")
34
+ values = st.slider(
35
+ 'Select a range of values',
36
+ 0.0, 100.0, (25.0, 75.0))
37
+ st.write('Values:', values)
38
+
39
+ appointment = st.slider(
40
+ "Schedule your appointment:",
41
+ value=(datetime.time(11, 30), datetime.time(12, 45)))
42
+ st.write("You're scheduled for:", appointment)
43
+
44
+ start_time = st.slider(
45
+ "When do you start?",
46
+ value=datetime.datetime(2020, 1, 1, 9, 30),
47
+ format="MM/DD/YY - hh:mm")
48
+ st.write("Start time:", start_time)
49
+
50
+
51
+ if st.button('Three cheers'):
52
+ st.toast('Hip!')
53
+ time.sleep(.5)
54
+ st.toast('Hip!')
55
+ time.sleep(.5)
56
+ st.toast('Hooray!', icon='🎉')
57
+
58
+
59
+ if "chat_messages" not in st.session_state:
60
+ st.session_state.chat_messages = []
61
+
62
+ prompt = st.chat_input("Say something")
63
+ if prompt:
64
+ st.session_state.chat_messages.append({"type": "user", "message": prompt})
65
+ st.session_state.chat_messages.append({"type": "bot", "message": "Hello!", "chart": np.random.randn(30, 3)})
66
+
67
+ for message in st.session_state.chat_messages[::-1]:
68
+ if message["type"] == "user":
69
+ with st.chat_message("You"):
70
+ st.write(message["message"])
71
+ else:
72
+ with st.chat_message("Bot"):
73
+ st.write(message["message"])
74
+ st.line_chart(message["chart"])