Araeynn commited on
Commit
64a8646
1 Parent(s): 6c85b5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -38
app.py CHANGED
@@ -1,40 +1,9 @@
1
- from flask import Flask, request
2
- import socket
3
- import multiprocessing
4
 
5
- app = Flask(__name__)
 
 
 
 
6
 
7
- @app.route('/execute', methods=['POST'])
8
- def execute_code():
9
- python_code = request.get_data(as_text=True)
10
-
11
- try:
12
- result = exec(python_code)
13
- return str(result)
14
- except Exception as e:
15
- return str(e)
16
-
17
- if __name__ == '__main__':
18
- def startServer():
19
- hostname = socket.gethostname()
20
-
21
- # Get the server's IP address
22
- ip_address = socket.gethostbyname(hostname)
23
-
24
- # Set the port number
25
- port = 12345
26
-
27
- # Print the URL
28
- print(f"Server running at http://{ip_address}:{port}/")
29
- app.run(host='0.0.0.0', port=12345)
30
- multiprocessing.Process(target=startServer).start()
31
- def startGradio():
32
- import gradio as gr
33
-
34
- def greet(name):
35
- return ""
36
-
37
- demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
38
-
39
- demo.launch(share=False)
40
- multiprocessing.Process(target=startGradio).start()
 
1
+ import gradio as gr
 
 
2
 
3
+ app = gr.Interface(
4
+ fn=exec,
5
+ inputs=["text"],
6
+ outputs=["text"],
7
+ )
8
 
9
+ app.launch()