|
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() |
|
|