File size: 2,820 Bytes
4212219
6d49af4
00b51d3
df7c4b9
 
 
6f309ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4212219
61eefa5
78a0ccd
 
61eefa5
 
 
24ab09f
 
 
 
 
 
92464ed
 
 
67e208d
 
1a169c1
1db4592
50abad8
 
 
 
6ee9e84
209dd54
24ab09f
 
 
84cffa3
0f5a1c3
b85d656
 
6db7efd
bb32577
b85d656
bb32577
6db7efd
d250462
 
6ee9e84
 
 
 
00b51d3
 
 
6ee9e84
9ac5932
 
6ee9e84
92464ed
cc88c8d
 
 
 
 
 
6f309ce
2425be7
cc88c8d
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import streamlit as st
import streamlit_authenticator as stauth
import pandas as pd
import matplotlib.pyplot as plt
from wordcloud import WordCloud

import sqlite3 
conn = sqlite3.connect('data.db')
c = conn.cursor()

def create_usertable():
  c.execute('CREATE TABLE IF NOT EXISTS userstable(username TEXT,password TEXT)')
  
def add_userdata(username,password):
  c.execute('INSERT INTO userstable(username,password) VALUES (?,?)',(username,password))
  conn.commit()
  
def login_user(username,password):
  c.execute('SELECT * FROM userstable WHERE username =? AND password = ?',(username,password))
  data = c.fetchall()
  return data
  
def view_all_users():
  c.execute('SELECT * FROM userstable')
  data = c.fetchall()
  return data


url = "https://cdn.pixabay.com/photo/2022/02/25/09/23/background-7033808_1280.jpg"

st.image(url)

a = st.sidebar.radio("SELECT -", ['HOME', 'Login', 'SignUp'])

if a == 'HOME' :
  st.title("Word Cloud Generator ๐Ÿ˜ถโ€๐ŸŒซ๏ธ")
  st.write("Follow steps -")
  st.write("1. Signup")
  st.write("2. Login")
  st.write("3. Select word cloud from tasks")
  st.write("4. Congratulations!")
  
elif a == 'Login' :
  st.title("Welecome Back... Login")
  username = st.text_input("User Name")
  password = st.text_input("Password",type='password')
  
  if st.checkbox("Login"):
    #if password == 'mlh2023' :
    create_usertable()
    result = login_user(username,password)
    if result:
      st.success("logged in as {}".format(username))
      
      task = st.selectbox("Task",['Word Cloud','Post your thoughts', 'Profiles'])
      if task == 'Word Cloud':
        st.subheader("This is  Word Cloud Generator")
        text = st.text_input("Your Text")
        if st.button('Confirm!'):
          st.write('Confirmed')
          word_cloud = WordCloud(collocations = False, background_color = 'white').generate(text)
          fig, ax = plt.subplots(figsize = (12, 8))
          plt.imshow(word_cloud, interpolation='bilinear')
          plt.axis("off")
          plt.show()
          st.pyplot(fig)
        else :
          st.write('')
      elif task == 'Post your thoughts':
        st.subheader("Thankyou for your Support")
      elif task == 'Profiles':
        st.subheader("Users profiles")
        user_result = view_all_users()
        clean_db = pd.DataFrame(user_result,columns=["Username","Password"])
        st.dataframe(clean_db)
      
    else:
      st.warning("Incorrect Password")  
   
elif a == 'SignUp' :
  st.title("Welecome New User")
  st.subheader("Create New Account")
  new_user = st.text_input("Username")
  new_password = st.text_input("Password",type='password')
  
  if st.button("SignUp"):
    create_usertable()
    add_userdata(new_user,new_password)
    st.success("Great! welecome to my secure app")
    st.info("Go to Login Menu to login")