Spaces:
Sleeping
Sleeping
Commit
·
437b70e
1
Parent(s):
17e2f40
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,25 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
|
| 3 |
-
# 安装单个包
|
| 4 |
-
package_name = "flask"
|
| 5 |
-
subprocess.check_call(["pip", "install", package_name])
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
-
from flask import Flask, session
|
| 9 |
-
app = Flask(__name__)
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
session["user_name"] += name
|
| 14 |
-
user_name = session["user_name"]
|
| 15 |
return "Hello " + user_name + "!!"
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# import subprocess
|
| 2 |
|
| 3 |
+
# # 安装单个包
|
| 4 |
+
# package_name = "flask"
|
| 5 |
+
# subprocess.check_call(["pip", "install", package_name])
|
| 6 |
|
| 7 |
import gradio as gr
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def greet(name, user_name):
|
| 10 |
+
user_name
|
|
|
|
|
|
|
| 11 |
return "Hello " + user_name + "!!"
|
| 12 |
|
| 13 |
+
with gr.Blocks() as demo:
|
| 14 |
+
user_name = gr.State(value='')
|
| 15 |
+
name_input = gr.Textbox(visible = True,lines=1, label='Name input')
|
| 16 |
+
name_output = gr.Textbox(visible = True,lines=1, label='Name output')
|
| 17 |
+
btn = gr.Button(value="Send")
|
| 18 |
+
btn.click(greet, inputs = [name_input, user_name], outputs=name_output)
|
| 19 |
+
demo.queue()
|
| 20 |
+
demo.launch() # server_port=7832, share=True
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 25 |
+
# iface.launch(app=app)
|