File size: 751 Bytes
007796f
fa3bb06
c6d46a6
007796f
1bdbce8
007796f
 
 
c6d46a6
007796f
 
 
 
 
 
 
fa3bb06
 
 
 
 
 
 
 
 
 
 
 
 
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
from flask import Flask, request
import multiprocessing

app = Flask(__name__)

@app.route('/execute', methods=['POST'])
def execute_code():
    python_code = request.get_data(as_text=True)
    
    try:
        result = exec(python_code)
        return str(result)
    except Exception as e:
        return str(e)

if __name__ == '__main__':
    def startServer():
        app.run(host='0.0.0.0', port=12345)
    multiprocessing.Process(target=startServer).start()
    def startGradio():
        import gradio as gr

        def greet(name):
            return ""
        
        demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
            
        demo.launch(share=False)
    multiprocessing.Process(target=startGradio).start()