添加js的支持

main
阳光少年 1 year ago
parent e35b1b6b6e
commit 6119ce19c8

@ -3,4 +3,4 @@ HOME=/home/rocker
VIRTUAL_ENV=/home/rocker/pypy_env
VIRTUAL_ENV_PROMPT=(pypy_env)
PATH=/home/rocker/go/go/bin:/home/rocker/pypy_env/bin:/home/rocker/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PATH=/home/rocker/node/bin:/home/rocker/go/go/bin:/home/rocker/pypy_env/bin:/home/rocker/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

@ -6,6 +6,7 @@ $ apt update
$ apt install sudo
$ apt install vim
$ apt install curl
$ apt install wget
$ apt install build-essential
# 安装 jupyter所需要的基础软件
$ apt install ca-certificates
@ -48,20 +49,24 @@ $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# rocker用户 安装g++
# 上面已经有了
# 安装node
$ mkdir node && cd node
$ wget https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz
$ tar xvf node-v14.17.0-linux-x64.tar.xz && rm -rf node-v14.17.0-linux-x64.tar.xz
$ cp -rf node-v14.17.0-linux-x64/* ./ && rm -rf node-v14.17.0-linux-x64
# 清空root和rocker用户的 .viminfo
$ echo > ~/.viminfo
# 清空root和rocker用户的 .viminfo
# 清空root和rocker用户的 history历史命令
$ history -c && echo > ~/.bash_history
$ echo > ~/.viminfo && history -c && echo > ~/.bash_history
# docker 导出
$ docker export CONTAINER > base_ubuntu_image.tar
# 解压后的操作, 解压后检查
$ tar -xvf base_ubuntu_image.tar
$ rm -rf base_ubuntu_image.tar
$ tar -xvf base_ubuntu_image.tar && rm -rf base_ubuntu_image.tar
# vi 编辑 etc/resolv.conf, 添加 nameserver 8.8.8.8
$ echo "nameserver 8.8.8.8" > etc/resolv.conf
@ -70,7 +75,7 @@ $ echo "nameserver 8.8.8.8" > etc/resolv.conf
$ echo "127.0.0.1 rocker" > etc/hosts
# 删除多余文件
$ rm -rf /.dockerenv
$ rm -rf .dockerenv
# 删除需要编译的语言 测试用生成的可执行程序(比如 rust/go/cpp)
$ rm -rf rust_project/target/rust_project

@ -48,13 +48,18 @@ fn main(){
}
"""
javascript_code = """
console.log("hello world~~")
"""
if __name__ == "__main__":
import requests
url = "http://127.0.0.1:8011"
# resp = requests.post(url, json={"code": python_code, "language": "python"})
# resp = requests.post(url, json={"code": cpp_code, "language": "cpp"})
# resp = requests.post(url, json={"code": go_code, "language": "go"})
resp = requests.post(url, json={"code": rust_code, "language": "rust"})
# resp = requests.post(url, json={"code": rust_code, "language": "rust"})
resp = requests.post(url, json={"code": javascript_code, "language": "javascript"})
print(resp.json()["msg"])

@ -3,7 +3,7 @@ import sys
import subprocess
import traceback
TARGET_LANGUAGE = set(["python", "cpp", "go", "rust"])
TARGET_LANGUAGE = set(["python", "cpp", "go", "rust", "node", "javascript"])
PROJECT_PATH = "/home/rocker/project"
def go_handler():
@ -27,7 +27,9 @@ def cpp_handler():
return "", main_path
def node_handler():
pass
main_path = f"{PROJECT_PATH}/node_project/main.js"
subprocess.run(["cp", "/tmp/code", main_path], capture_output=True)
return "", main_path
def rust_handler():
source_path = f"{PROJECT_PATH}/rust_project/src/main.rs"
@ -65,12 +67,14 @@ def main():
err, main_path = go_handler()
cmd.extend([main_path])
elif language == "node":
pass
err, main_path = node_handler()
cmd.extend(["node", main_path])
elif language == "rust":
err, main_path = rust_handler()
cmd.extend([main_path])
elif language == "javascript":
node_handler()
err, main_path = node_handler()
cmd.extend(["node", main_path])
else:
...

Loading…
Cancel
Save