Pijush2023 commited on
Commit
a6262a3
·
verified ·
1 Parent(s): dcf6adc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -8
app.py CHANGED
@@ -835,12 +835,78 @@ def update_images():
835
 
836
 
837
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
838
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
839
-
840
  with gr.Row():
841
  with gr.Column():
842
- state = gr.State()
 
 
 
 
 
 
 
 
 
 
 
 
 
843
 
 
844
  chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
845
  choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
846
 
@@ -853,7 +919,6 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
853
  clear_button = gr.Button("Clear")
854
  clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
855
 
856
-
857
  audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
858
  audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
859
 
@@ -867,14 +932,11 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
867
  news_output = gr.HTML(value=fetch_local_events())
868
 
869
  with gr.Column():
870
-
871
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
872
  image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
873
  image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
874
-
875
-
876
  refresh_button = gr.Button("Refresh Images")
877
  refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
878
-
879
  demo.queue()
880
- demo.launch(share=True)
 
835
 
836
 
837
 
838
+ import sqlite3
839
+ import bcrypt
840
+
841
+ # Create a database connection
842
+ conn = sqlite3.connect('user_data.db')
843
+ c = conn.cursor()
844
+
845
+ # Create users table
846
+ c.execute('''
847
+ CREATE TABLE IF NOT EXISTS users (
848
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
849
+ email TEXT UNIQUE NOT NULL,
850
+ password TEXT NOT NULL
851
+ )
852
+ ''')
853
+ conn.commit()
854
+ conn.close()
855
+
856
+
857
+ def hash_password(password):
858
+ return bcrypt.hashpw(password.encode(), bcrypt.gensalt())
859
+
860
+ def check_password(password, hashed):
861
+ return bcrypt.checkpw(password.encode(), hashed)
862
+
863
+ def signup_user(email, password):
864
+ conn = sqlite3.connect('user_data.db')
865
+ c = conn.cursor()
866
+ try:
867
+ c.execute("INSERT INTO users (email, password) VALUES (?, ?)", (email, hash_password(password)))
868
+ conn.commit()
869
+ return "User signed up successfully!"
870
+ except sqlite3.IntegrityError:
871
+ return "Email already registered!"
872
+ finally:
873
+ conn.close()
874
+
875
+ def login_user(email, password):
876
+ conn = sqlite3.connect('user_data.db')
877
+ c = conn.cursor()
878
+ c.execute("SELECT password FROM users WHERE email = ?", (email,))
879
+ result = c.fetchone()
880
+ conn.close()
881
+ if result and check_password(password, result[0]):
882
+ return "Login successful!"
883
+ else:
884
+ return "Invalid email or password!"
885
+
886
+
887
+
888
+
889
+
890
+
891
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
 
892
  with gr.Row():
893
  with gr.Column():
894
+ gr.Markdown("<h1>Welcome to the App</h1>")
895
+ with gr.Tab("Sign Up"):
896
+ signup_email = gr.Textbox(placeholder="Email")
897
+ signup_password = gr.Password(placeholder="Password")
898
+ signup_button = gr.Button("Sign Up")
899
+ signup_output = gr.Textbox(interactive=False)
900
+ signup_button.click(signup, inputs=[signup_email, signup_password], outputs=signup_output)
901
+
902
+ with gr.Tab("Login"):
903
+ login_email = gr.Textbox(placeholder="Email")
904
+ login_password = gr.Password(placeholder="Password")
905
+ login_button = gr.Button("Login")
906
+ login_output = gr.Textbox(interactive=False)
907
+ login_button.click(login, inputs=[login_email, login_password], outputs=login_output)
908
 
909
+ state = gr.State()
910
  chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
911
  choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
912
 
 
919
  clear_button = gr.Button("Clear")
920
  clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
921
 
 
922
  audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
923
  audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
924
 
 
932
  news_output = gr.HTML(value=fetch_local_events())
933
 
934
  with gr.Column():
 
935
  image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
936
  image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
937
  image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
 
 
938
  refresh_button = gr.Button("Refresh Images")
939
  refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
940
+
941
  demo.queue()
942
+ demo.launch(share=True)