kmaurinjones commited on
Commit
41b71e6
1 Parent(s): d37d610

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -5
app.py CHANGED
@@ -17,13 +17,57 @@ delay_min = st.number_input(label = "Minimum delay per iteration. We recommend a
17
  delay_max = st.number_input(label = "Maximum delay per iteration. We recommend a value of at least 10 seconds per song, otherwise you may be banned from azlyrics.com for scraping.",
18
  step = 1., format = "%.2f", value = float(20))
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # user-provided data
21
  artist_name = st.text_input("Enter artist name here")
22
- song_1 = st.text_input("Enter 1st song title here")
23
- song_2 = st.text_input("Enter 2nd song title here")
24
- song_3 = st.text_input("Enter 3rd song title here")
25
- song_4 = st.text_input("Enter 4th song title here")
26
- song_5 = st.text_input("Enter 5th song title here")
 
 
 
 
27
 
28
  # funnies
29
  funnies = []
 
17
  delay_max = st.number_input(label = "Maximum delay per iteration. We recommend a value of at least 10 seconds per song, otherwise you may be banned from azlyrics.com for scraping.",
18
  step = 1., format = "%.2f", value = float(20))
19
 
20
+ ######################################################################################################################################################
21
+
22
+ # Define a function to handle the state of the input fields
23
+ def manage_input_fields(session_state):
24
+ if "input_fields" not in session_state:
25
+ session_state.input_fields = [{}]
26
+
27
+ # Render the input fields
28
+ for index, input_field in enumerate(session_state.input_fields):
29
+ value = st.text_input(f"Text Input {index + 1}", key=f"text_input_{index}")
30
+ input_field["value"] = value
31
+
32
+ # Check if the last field is empty and add a new field
33
+ if session_state.input_fields[-1]["value"]:
34
+ session_state.input_fields.append({})
35
+
36
+ # Main function
37
+ def main():
38
+ st.title("Dynamic Text Inputs with Streamlit")
39
+
40
+ # Initialize the session state
41
+ if "session_state" not in st.session_state:
42
+ st.session_state["session_state"] = {}
43
+
44
+ session_state = st.session_state["session_state"]
45
+
46
+ # Manage input fields
47
+ manage_input_fields(session_state)
48
+
49
+ # Add a submit button
50
+ if st.button("Submit"):
51
+ st.write("Values submitted:")
52
+ for index, input_field in enumerate(session_state.input_fields[:-1]):
53
+ st.write(f"Text Input {index + 1}: {input_field['value']}")
54
+
55
+ if __name__ == "__main__":
56
+ main()
57
+
58
+ ######################################################################################################################################################
59
+
60
  # user-provided data
61
  artist_name = st.text_input("Enter artist name here")
62
+ song_1 = st.text_input("Enter 1st song title here", value = "jn mayer") # delete this when done
63
+ if song_1:
64
+ song_2 = st.text_input("Enter 2nd song title here")
65
+ if song_2:
66
+ song_3 = st.text_input("Enter 3rd song title here")
67
+ if song_3:
68
+ song_4 = st.text_input("Enter 4th song title here")
69
+ if song_4:
70
+ song_5 = st.text_input("Enter 5th song title here")
71
 
72
  # funnies
73
  funnies = []