调整结构

main
阳光少年 1 year ago
parent 49e5ca1f16
commit 6f30093001

@ -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__":

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

Loading…
Cancel
Save