Spaces:
Running
Running
first update
Browse files- .gradio/certificate.pem +31 -0
- app.py +58 -0
.gradio/certificate.pem
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----BEGIN CERTIFICATE-----
|
2 |
+
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
3 |
+
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
4 |
+
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
|
5 |
+
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
|
6 |
+
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
|
7 |
+
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
|
8 |
+
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
|
9 |
+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
|
10 |
+
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
|
11 |
+
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
|
12 |
+
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
|
13 |
+
B5iPN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vh+wjChP4kqKOJ2qxq
|
28 |
+
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
|
29 |
+
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
|
30 |
+
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
|
31 |
+
-----END CERTIFICATE-----
|
app.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Simulated user data for demonstration
|
4 |
+
user_data = {"hello": "hello"}
|
5 |
+
|
6 |
+
# Sample English text to translate
|
7 |
+
english_text = "Translate this text to Vietnamese."
|
8 |
+
|
9 |
+
# User session dictionary to store logged-in status
|
10 |
+
user_sessions = {}
|
11 |
+
|
12 |
+
def login(username, password):
|
13 |
+
# Authenticate user
|
14 |
+
if username in user_data and user_data[username] == password:
|
15 |
+
user_sessions[username] = True
|
16 |
+
return f"Welcome, {username}!", gr.update(visible=False), gr.update(visible=True)
|
17 |
+
else:
|
18 |
+
return "Invalid username or password.", gr.update(visible=True), gr.update(visible=False)
|
19 |
+
|
20 |
+
def logout(username):
|
21 |
+
# Log out user and reset session
|
22 |
+
if username in user_sessions:
|
23 |
+
del user_sessions[username]
|
24 |
+
return "Logged out. Please log in again.", gr.update(visible=True), gr.update(visible=False)
|
25 |
+
|
26 |
+
def submit_translation(translation):
|
27 |
+
# Save the translation and provide feedback
|
28 |
+
return f"Translation submitted: {translation}"
|
29 |
+
|
30 |
+
# Define the Gradio interface
|
31 |
+
with gr.Blocks() as demo:
|
32 |
+
# Login section
|
33 |
+
with gr.Column(visible=True) as login_section:
|
34 |
+
username_input = gr.Textbox(placeholder="Enter your username", label="Username")
|
35 |
+
password_input = gr.Textbox(placeholder="Enter your password", label="Password", type="password")
|
36 |
+
login_button = gr.Button("Login")
|
37 |
+
login_output = gr.Textbox(label="Login Status", interactive=False)
|
38 |
+
|
39 |
+
# Translation section (initially hidden)
|
40 |
+
with gr.Column(visible=False) as translation_section:
|
41 |
+
gr.Textbox(value=english_text, label="English Text", interactive=False)
|
42 |
+
translation_input = gr.Textbox(placeholder="Enter your translation here", label="Your Translation")
|
43 |
+
submit_button = gr.Button("Submit Translation")
|
44 |
+
translation_output = gr.Textbox(label="Submission Status", interactive=False)
|
45 |
+
logout_button = gr.Button("Logout")
|
46 |
+
|
47 |
+
# Button functions
|
48 |
+
login_button.click(
|
49 |
+
login, inputs=[username_input, password_input], outputs=[login_output, login_section, translation_section]
|
50 |
+
)
|
51 |
+
submit_button.click(
|
52 |
+
submit_translation, inputs=translation_input, outputs=translation_output
|
53 |
+
)
|
54 |
+
logout_button.click(
|
55 |
+
logout, inputs=[username_input], outputs=[login_output, login_section, translation_section]
|
56 |
+
)
|
57 |
+
|
58 |
+
demo.launch()
|