Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This is a simple Gradio app that greets the user and is protected by username and password.
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Define a function that takes a name and returns a greeting.
|
| 5 |
+
def greet(name):
|
| 6 |
+
return "Hello " + name + "!"
|
| 7 |
+
|
| 8 |
+
# Create a Gradio interface that takes a textbox input, runs it through the greet function, and returns output to a textbox.
|
| 9 |
+
demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
|
| 10 |
+
|
| 11 |
+
# Define the username and password for authentication.
|
| 12 |
+
def auth(username, password):
|
| 13 |
+
return username == "user" and password == "pass"
|
| 14 |
+
|
| 15 |
+
# Launch the interface on Hugging Face Spaces with authentication.
|
| 16 |
+
demo.launch(share=True, auth=auth, show_error=True)
|