diff --git a/test/service/client.py b/test/service/client.py index 1c2ceb3..55fc202 100644 --- a/test/service/client.py +++ b/test/service/client.py @@ -2,9 +2,16 @@ code = """ import time import os +import http.client + print("hello world") print(os.environ) +print(os.listdir()) + +conn = http.client.HTTPConnection("www.baidu.com") +conn.request("GET", "/") +print(conn.getresponse().read().decode('utf-8')) """ if __name__ == "__main__": diff --git a/test/service/server.py b/test/service/server.py index e22532e..9c8cf33 100644 --- a/test/service/server.py +++ b/test/service/server.py @@ -9,12 +9,15 @@ app = Flask(__name__) USER_NAME = "ubuntu" ROCKER_PATH = f"/home/{USER_NAME}/rocker/target/debug/rocker" + @app.route("/", methods=["POST"]) -def hello_world(): +def main(): + code = request.json.get("code", "") + _id = str(random.randint(8000_0000, 9000_0000)) user_path = f"/tmp/{_id}" os.mkdir(user_path) - code = request.json.get("code", "") + with open(f"{user_path}/main.py", "w") as f: f.write(code)