File size: 1,564 Bytes
d315945
 
 
 
 
 
 
 
 
 
 
 
f60efdc
 
 
 
d315945
f60efdc
d315945
 
f60efdc
d315945
f60efdc
d315945
 
 
f60efdc
 
 
d315945
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
import os
from util.data import get_data

# Page Description
st.title("Benchmark Data Download")
st.write("""
Welcome to the Online Data Sample Download page. Please enter the password to access and download data samples.
Once verified, you can specify the number of samples you wish to retrieve and download the data as a CSV file.
""")


def check_password():
    def password_entered():
        if password_input == os.getenv('PASSWORD'):
            st.session_state['password_correct'] = True
        else:
            st.error("Incorrect Password, please try again.")

    password_input = st.text_input("Enter Password:", type="password")
    submit_button = st.button("Submit", on_click=password_entered)

    if submit_button and not st.session_state.get('password_correct', False):
        st.error("Please enter a valid password to access the demo.")



if not st.session_state.get('password_correct', False):
    check_password()
else:
    st.sidebar.success("Password Verified. Proceed with the demo.")

    # Allow user to set the number of samples
    num_samples = st.sidebar.number_input(
        "Set number of samples:",
        min_value=1,
        max_value=100,
        value=5
    )

    # Load and display data
    data = get_data(num_samples)
    st.dataframe(data['question'])

    # Create a CSV download link
    csv = data['question'].to_csv(index=False)
    st.download_button(
        label="Download data samples as CSV",
        data=csv,
        file_name='data_samples.csv',
        mime='text/csv',
    )