Spaces:
Runtime error
Runtime error
Commit
·
ddd3ad6
1
Parent(s):
57534ab
app.py
CHANGED
@@ -1,13 +1,4 @@
|
|
1 |
-
import
|
2 |
-
def update(name):
|
3 |
-
return f"Welcome to Gradio, {name}!"
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
with gr.Row():
|
8 |
-
inp = gr.Textbox(placeholder="What is your name?")
|
9 |
-
out = gr.Textbox()
|
10 |
-
btn = gr.Button("Run")
|
11 |
-
btn.click(fn=update, inputs=inp, outputs=out)
|
12 |
-
|
13 |
-
demo.launch()
|
|
|
1 |
+
import uvicorn
|
|
|
|
|
2 |
|
3 |
+
if __name__ == "__main__":
|
4 |
+
uvicorn.run("main:app", host="127.0.0.1", port=7860, reload=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client.py
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
|
3 |
-
# Replace this with the URL of your Hugging Face Space
|
4 |
-
api_url = "https://huggingface.co/spaces/iceberg0142/test/gradio"
|
5 |
-
|
6 |
-
# Define the input data
|
7 |
-
input_data = {"input": "Hello, Hugging Face!"}
|
8 |
-
|
9 |
-
# Make a POST request to the Space
|
10 |
-
response = requests.get(api_url)
|
11 |
-
|
12 |
-
# Print the response
|
13 |
-
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
@app.get("/predict")
|
7 |
+
def read_main():
|
8 |
+
return {"message": "This is your main app"}
|
9 |
+
|
10 |
+
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
11 |
+
app = gr.mount_gradio_app(app, io, path="/")
|
12 |
+
|
13 |
+
# # Launch the app (which will be hosted on Hugging Face Spaces)
|
14 |
+
# io.launch()
|
run.py
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
import uvicorn
|
2 |
-
|
3 |
-
if __name__ == "__main__":
|
4 |
-
uvicorn.run("app:app", host="127.0.0.1", port=8000, reload=True)
|
|
|
|
|
|
|
|
|
|