Ramesh-vani commited on
Commit
57193ba
1 Parent(s): 01531ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -19
app.py CHANGED
@@ -3,30 +3,29 @@ import subprocess
3
 
4
  def run_command(command):
5
  process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6
- output, error = process.communicate()
7
- if process.returncode == 0:
8
- result = output.decode('utf-8')
9
- return result
10
- else:
11
- result = error.decode('utf-8')
12
- return result
13
 
14
  # Example usage
15
 
16
-
17
  def my_inference_function(name):
18
- return "Hello " + name + "!"
19
 
20
  gradio_interface = gradio.Interface(
21
- fn=run_command,
22
- inputs="text",
23
- outputs="text",
24
- examples=[
25
- ["ls -l"],
26
- ["pip install bs4"]
27
- ],
28
- title="REST API with Gradio and Huggingface Spaces",
29
- description="This is a demo of how to build an AI powered REST API with Gradio and Huggingface Spaces – for free! Based on [this article](https://www.tomsoderlund.com/ai/building-ai-powered-rest-api). See the **Use via API** link at the bottom of this page.",
30
- article="© Tom Söderlund 2022"
31
  )
32
  gradio_interface.launch()
 
3
 
4
  def run_command(command):
5
  process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6
+ output, error = process.communicate()
7
+ if process.returncode == 0:
8
+ result = output.decode('utf-8')
9
+ return result
10
+ else:
11
+ result = error.decode('utf-8')
12
+ return result
13
 
14
  # Example usage
15
 
 
16
  def my_inference_function(name):
17
+ return "Hello " + name + "!"
18
 
19
  gradio_interface = gradio.Interface(
20
+ fn=run_command,
21
+ inputs="text",
22
+ outputs="text",
23
+ examples=[
24
+ ["ls -l"],
25
+ ["pip install bs4"]
26
+ ],
27
+ title="REST API with Gradio and Huggingface Spaces",
28
+ description="This is a demo of how to build an AI powered REST API with Gradio and Huggingface Spaces – for free! Based on [this article](https://www.tomsoderlund.com/ai/building-ai-powered-rest-api). See the **Use via API** link at the bottom of this page.",
29
+ article="© Tom Söderlund 2022"
30
  )
31
  gradio_interface.launch()