diff --git a/test/service/client.py b/test/service/client.py index 4d239e7..034ff4f 100644 --- a/test/service/client.py +++ b/test/service/client.py @@ -1,19 +1,16 @@ -import requests -URL = "http://192.168.230.132:8011" code = """ import time +import os print("hello world") -cnt = 0 -while True: - print(cnt) - cnt += 1 - time.sleep(0.1) - +print(os.environ) """ -resp = requests.post(URL, json={"code": code}) -print(resp.json()["msg"]) +if __name__ == "__main__": + import requests + url = "http://127.0.0.1:8011" + resp = requests.post(url, json={"code": code}) + print(resp.json()["msg"]) diff --git a/test/service/server.py b/test/service/server.py index 2de20ca..9518c66 100644 --- a/test/service/server.py +++ b/test/service/server.py @@ -4,8 +4,10 @@ import os import subprocess import time + app = Flask(__name__) -ROCKER_PATH = "/home/yanguangshaonian/rocker/target/debug/rocker" +USER_NAME = "ubuntu" +ROCKER_PATH = f"/home/{USER_NAME}/rocker/target/debug/rocker" @app.route("/", methods=["POST"]) def hello_world(): @@ -21,7 +23,7 @@ def hello_world(): "--id", _id, "--image", "ubuntu_pypy_numpy_pandas_user", "--run", "python -u /tmp/main.py", - "--env", "/home/yanguangshaonian/rocker/pypy.env", + "--env", f"/home/{USER_NAME}/rocker/pypy.env", "--volume", f"{user_path}:/tmp", "--log"]) except Exception as e: @@ -45,4 +47,4 @@ def hello_world(): return {"msg": out, code: code, "id": _id} if __name__ == "__main__": - app.run(host='0.0.0.0', port=8011) \ No newline at end of file + app.run(host='0.0.0.0', port=8011, threaded=True) \ No newline at end of file