服务功能更新

main
阳光少年 1 year ago
parent dc3fc432b5
commit 5dd19a184b

@ -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})
if __name__ == "__main__":
import requests
url = "http://127.0.0.1:8011"
resp = requests.post(url, json={"code": code})
print(resp.json()["msg"])

@ -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)
app.run(host='0.0.0.0', port=8011, threaded=True)
Loading…
Cancel
Save