Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,12 @@ import textflowsms as tf
|
|
7 |
api_key = os.getenv('API_KEY')
|
8 |
tf.useKey(api_key)
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
# Initialize session state variables if they don't exist
|
11 |
if 'phone_number' not in st.session_state:
|
12 |
st.session_state['phone_number'] = '9522583980' # Default phone number
|
@@ -32,7 +38,8 @@ def append_to_log(phone_number):
|
|
32 |
log_file.write(f"{phone_number}\n")
|
33 |
|
34 |
# Mobile Phone field with emoji
|
35 |
-
st.sidebar.text_input("π± Mobile Phone",
|
|
|
36 |
|
37 |
# Password field with emoji
|
38 |
password_input = st.sidebar.text_input("π Set Password", type='password')
|
@@ -45,8 +52,9 @@ if st.sidebar.button('Save Password'):
|
|
45 |
|
46 |
# Function to send verification SMS
|
47 |
def send_verification_sms():
|
|
|
48 |
verification_url = f"{base_url}?hash={st.session_state['password']}"
|
49 |
-
tf.sendSMS(recipient=
|
50 |
st.sidebar.success("Verification link sent via SMS")
|
51 |
|
52 |
# Check if the hash parameter is provided
|
|
|
7 |
api_key = os.getenv('API_KEY')
|
8 |
tf.useKey(api_key)
|
9 |
|
10 |
+
# Function to ensure phone number is correctly formatted
|
11 |
+
def format_phone_number(phone_number):
|
12 |
+
if len(phone_number) == 10 and not phone_number.startswith('+'):
|
13 |
+
return '+1' + phone_number
|
14 |
+
return phone_number
|
15 |
+
|
16 |
# Initialize session state variables if they don't exist
|
17 |
if 'phone_number' not in st.session_state:
|
18 |
st.session_state['phone_number'] = '9522583980' # Default phone number
|
|
|
38 |
log_file.write(f"{phone_number}\n")
|
39 |
|
40 |
# Mobile Phone field with emoji
|
41 |
+
user_phone_input = st.sidebar.text_input("π± Mobile Phone", value=st.session_state.get('phone_number', ''))
|
42 |
+
st.session_state['phone_number'] = format_phone_number(user_phone_input)
|
43 |
|
44 |
# Password field with emoji
|
45 |
password_input = st.sidebar.text_input("π Set Password", type='password')
|
|
|
52 |
|
53 |
# Function to send verification SMS
|
54 |
def send_verification_sms():
|
55 |
+
formatted_phone_number = format_phone_number(st.session_state['phone_number'])
|
56 |
verification_url = f"{base_url}?hash={st.session_state['password']}"
|
57 |
+
tf.sendSMS(recipient=formatted_phone_number, text=f"Verify here: {verification_url}")
|
58 |
st.sidebar.success("Verification link sent via SMS")
|
59 |
|
60 |
# Check if the hash parameter is provided
|