You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
2.0 KiB
47 lines
2.0 KiB
import fs from "fs";
|
|
import child_process from "node:child_process";
|
|
|
|
app.post("/apistu/pppta",async (req,res)=>{
|
|
const sqlread="SELECT * FROM tmj_ex WHERE id=?"
|
|
const resultptainfor=await new Promise((resolve, reject) => {
|
|
connection.query(sqlread,[req.body.uuid],(error,results,fields)=>{
|
|
resolve(results[0]);
|
|
})
|
|
})
|
|
let information=JSON.parse(resultptainfor.tmlist)[parseInt(req.body.th)]
|
|
res.send(JSON.parse(information.information))
|
|
let tmlist=JSON.parse(information.information).testprint
|
|
let uuid1=uuidv4.v4()
|
|
let worktemp="C:\\Users\\l\\Music\\reat\\src\\MarkdownEditor\\test\\"+uuid1
|
|
fs.mkdirSync(worktemp)
|
|
if(req.body.pl==="java") {
|
|
fs.writeFileSync(worktemp + "\\Main.java", req.body.code)
|
|
|
|
fs.writeFileSync(worktemp + "\\inputby.txt", "work")
|
|
tmlist.map((tmone, index) => {
|
|
fs.writeFileSync(worktemp + "\\input" + (index + 1) + ".txt", tmone)
|
|
})
|
|
child_process.execFileSync(`python`, ["C:\\Users\\l\\PycharmProjects\\PythonProject7\\py2.py", worktemp, "java", 1])
|
|
let json_wb = fs.readFileSync(worktemp + "\\zt.json").toString()
|
|
let json_zt = JSON.parse(json_wb)
|
|
let zt_1 = [...json_zt.test]
|
|
if (json_zt.by === 0) {
|
|
let work_result = [...tmlist]
|
|
tmlist.map((tmresult, indexresult) => {
|
|
zt_1[index].by = 0
|
|
zt_1[index].sc = fs.readFileSync(worktemp + "\\output1.txt", {encoding: "utf8"})
|
|
zt_1[index].err = fs.readFileSync(worktemp + "\\err1.txt", {encoding: "utf8"})
|
|
zt_1[index] = {...zt_1[index], ...tmresult}
|
|
})
|
|
//zt_1.by=0
|
|
//zt_1.sc=fs.readFileSync(worktemp+"\\output1.txt",{encoding:"utf8"})
|
|
//zt_1.err=fs.readFileSync(worktemp+"\\err1.txt",{encoding:"utf8"})
|
|
}else {
|
|
let by_err={}
|
|
by_err.by=json_zt.by
|
|
by_err.err=fs.readFileSync(worktemp+"\\err_by.txt",{encoding:"utf8"})
|
|
}
|
|
|
|
}
|
|
})
|