Showing
2 changed files
with
29 additions
and
7 deletions
... | @@ -22,7 +22,7 @@ export class PostController { | ... | @@ -22,7 +22,7 @@ export class PostController { |
22 | body.example, | 22 | body.example, |
23 | body.testinput, | 23 | body.testinput, |
24 | body.testoutput, | 24 | body.testoutput, |
25 | - body.level, | 25 | + body.difficulty, |
26 | ); | 26 | ); |
27 | } | 27 | } |
28 | 28 | ||
... | @@ -37,7 +37,7 @@ export class PostController { | ... | @@ -37,7 +37,7 @@ export class PostController { |
37 | body.example, | 37 | body.example, |
38 | body.testinput, | 38 | body.testinput, |
39 | body.testoutput, | 39 | body.testoutput, |
40 | - body.level, | 40 | + body.difficulty, |
41 | ); | 41 | ); |
42 | } | 42 | } |
43 | 43 | ... | ... |
... | @@ -46,6 +46,9 @@ export class RunnerService { | ... | @@ -46,6 +46,9 @@ export class RunnerService { |
46 | case 'ts': { | 46 | case 'ts': { |
47 | this.ts(body, location); | 47 | this.ts(body, location); |
48 | } | 48 | } |
49 | + case 'py': { | ||
50 | + this.py(body, location); | ||
51 | + } | ||
49 | } | 52 | } |
50 | } | 53 | } |
51 | c(body: any, location: string) { | 54 | c(body: any, location: string) { |
... | @@ -90,13 +93,10 @@ export class RunnerService { | ... | @@ -90,13 +93,10 @@ export class RunnerService { |
90 | shell: true, | 93 | shell: true, |
91 | }); | 94 | }); |
92 | console.log(test.stderr); | 95 | console.log(test.stderr); |
93 | - const result = child_process.spawnSync( | 96 | + const result = child_process.spawnSync('./tmp', { |
94 | - '.' + location.slice(0, location.length - 4), | ||
95 | - { | ||
96 | encoding: 'utf8', | 97 | encoding: 'utf8', |
97 | shell: true, | 98 | shell: true, |
98 | - }, | 99 | + }); |
99 | - ); | ||
100 | console.log(result.stdout); | 100 | console.log(result.stdout); |
101 | output.push(result.stdout as string); | 101 | output.push(result.stdout as string); |
102 | } | 102 | } |
... | @@ -186,6 +186,28 @@ export class RunnerService { | ... | @@ -186,6 +186,28 @@ export class RunnerService { |
186 | } | 186 | } |
187 | return output; | 187 | return output; |
188 | } | 188 | } |
189 | + | ||
190 | + py(body: any, location: string) { | ||
191 | + const output: Array<string> = []; | ||
192 | + if (body.input == []) { | ||
193 | + const result = child_process.spawnSync('python3', [location], { | ||
194 | + encoding: 'utf8', | ||
195 | + shell: true, | ||
196 | + }); | ||
197 | + console.log(result.stdout); | ||
198 | + output.push(result.stdout as string); | ||
199 | + } | ||
200 | + for (const ip of body.input) { | ||
201 | + const result = child_process.spawnSync('python3', [location], { | ||
202 | + encoding: 'utf8', | ||
203 | + shell: true, | ||
204 | + input: ip, | ||
205 | + }); | ||
206 | + console.log(result.stdout); | ||
207 | + output.push(result.stdout as string); | ||
208 | + } | ||
209 | + return output; | ||
210 | + } | ||
189 | // ts() { | 211 | // ts() { |
190 | // if ((this.input = [])) { | 212 | // if ((this.input = [])) { |
191 | // const test = child_process.spawnSync( | 213 | // const test = child_process.spawnSync( | ... | ... |
-
Please register or login to post a comment