File size: 1,818 Bytes
b449132
 
 
 
 
 
 
c64e7dc
b449132
c64e7dc
b449132
 
 
 
 
c64e7dc
b449132
 
 
 
 
 
a8c2ec4
 
b449132
c64e7dc
 
a8c2ec4
 
6f63bac
a8c2ec4
 
 
 
 
ea8ee4c
a8c2ec4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ea8ee4c
a8c2ec4
441e6b7
 
a8c2ec4
 
e2e999a
a8c2ec4
 
e2e999a
a8c2ec4
 
6f63bac
a8c2ec4
 
6f63bac
a8c2ec4
 
e2e999a
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
68
69
70
71
72
73
74
75
76
77
78
# # import gradio as gr

# def my_function(name):
#     return "Hello " + name + "!!"

# # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
# # iface.launch()
# import gradio as gr
# import requests

# # Create a Gradio app.
# app = gr.Interface(fn=my_function, inputs=['text'], outputs=['text'])

# # Get the URL of the Gradio app.
# url = app.launch()

# # Make a POST request to the URL of the Gradio app.
# data = {'text': 'This is a test.'}
# response = requests.post(url, data=data)

# # The response to the POST request will be the output of the Gradio app.
# output = response.json()['text']
# import gradio as gr
# import requests



# def my_function(name):
#     return "Hello " + name + "!!"
    
# # Create a Gradio app.
# app = gr.Interface(fn=my_function, inputs=['text'], outputs=['text'], allow_external_requests=True)

# # Launch the Gradio app.
# app.launch()

# # Make a GET request to the URL of the Gradio app.
# data = {'text': 'This is a test.'}
# response = requests.get(app.url, data=data)

# # The response to the GET request will be a JSON object.
# output = response.json()['output']

# # The input that you entered will be in the `input` key of the JSON object.
# input = response.json()['input']

# # Print the output and input.
# print(output)
# print(input)

import gradio

# Create a Gradio app.
interface = gradio.Interface(
  fn=predict,
  inputs=[gradio.inputs.Textbox()],
  outputs=[gradio.outputs.Text()],
)

# Add a `predict()` method to the Gradio app.
def predict(name):
    return "Hello " + name + "!!"
  # Use the model to predict the output.
  output = model(text)

  # Return the output.
  return output

# Save the Gradio app.
interface.save("my_app")

# Deploy the Gradio app.
interface.deploy()

# Create a post API endpoint.
interface.create_post_api()