File size: 2,687 Bytes
0392324
 
 
 
 
fbb7c49
0392324
ef84f3a
0392324
 
 
 
44df0dd
0392324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58a91e1
0392324
 
 
 
44df0dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbb7c49
a648bd3
99ff8e6
53c5d8a
99ff8e6
 
 
fbb7c49
44df0dd
 
 
0392324
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
import json
import requests

import streamlit as st

def login():

    base_url = 'https://caffeinecrew-techdocs.hf.space'


    headers={"accept":"application/json"}

    tab1, tab2 = st.tabs(["Login", "Signup"])

    with tab1:
        with st.form(key="myform2"):
            username = st.text_input(label="Username", label_visibility="collapsed", placeholder="Username")
            password = st.text_input(label="Password", label_visibility="collapsed", placeholder="Password", type="password")
            login_button = st.form_submit_button(label="Login")

        with st.spinner("Logging in..."):
            if login_button:
                try:
                    credentials = {"username":username, "password":password}
                    response = requests.post(base_url + "/auth/login", headers=headers, data=json.dumps(credentials)) 
                    if (response.status_code!=200):
                        raise Exception("Login Failed")
                    # res_dict.update(response.json())
                    st.session_state["username"] = username
                    st.session_state["access_token"] = response.json()['access_token']
                    st.session_state["refresh_token"] = response.json()['refresh_token']
                    st.success("Logged in successfully")
                    st.rerun()

                except Exception as e:
                    st.error(e)

    with tab2:
        with st.form(key="myform1"):
            username = st.text_input(label="Username", label_visibility="collapsed", placeholder="Username")
            password = st.text_input(label="Password", label_visibility="collapsed", placeholder="Password", type="password")
            email = st.text_input(label="Email", label_visibility="collapsed", placeholder="Email")
            signup_button = st.form_submit_button(label="Signup")

        with st.spinner("Signing up..."):
            if signup_button:
                try:
                    credentials = {"username":username, "password":password, "email":email}
                    response = requests.post(url=base_url + "/auth/signup", headers=headers, data=json.dumps(credentials))
                    if (response.status_code!=200):
                        raise Exception("Signup Failed")
                
                    st.success("Signed up successfully")
                except:
                    st.error("Signup Failed")

    st.divider()                
    st.subheader(":rainbow[Our Prototype in Action ]🎬")      
    with st.expander("Demo video 🎬",expanded=True):
        st.video("frontend/images/Showcase.mp4")