From 62a99938bb34cd45fa1420d8f86cc6bee1577ace Mon Sep 17 00:00:00 2001 From: "hugo.pradier2" Date: Mon, 15 Jan 2024 08:32:42 +0100 Subject: [PATCH] Envoie le langage au serveur --- src/app/components/editor/editor.component.ts | 8 ++++---- src/app/services/codeExecution.service.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/components/editor/editor.component.ts b/src/app/components/editor/editor.component.ts index 3f5f0a6..7587211 100644 --- a/src/app/components/editor/editor.component.ts +++ b/src/app/components/editor/editor.component.ts @@ -62,15 +62,15 @@ export class EditorComponent implements OnInit{ onRunButtonClicked() { // Le code à exécuter est le contenu de l'éditeur const codeToExecute = this.editorContent; - - this.codeExecutionService.executeCode(codeToExecute).subscribe( + + this.codeExecutionService.executeCode(codeToExecute, this.mode).subscribe( (response) => { console.log('Réponse du serveur:', response); console.log('Code qui va être exécuté:', codeToExecute); - + // Redirigez vers une autre page (par exemple, 'output') this.router.navigate(['/output']); - }, + }, (error) => { console.error('Erreur lors de l\'exécution du code:', error); } diff --git a/src/app/services/codeExecution.service.ts b/src/app/services/codeExecution.service.ts index a487009..f4cd893 100644 --- a/src/app/services/codeExecution.service.ts +++ b/src/app/services/codeExecution.service.ts @@ -10,7 +10,7 @@ export class CodeExecutionService { constructor(private http: HttpClient) {} - executeCode(code: string): Observable { - return this.http.post(this.apiUrl, { code }); + executeCode(code: string, language: string): Observable { + return this.http.post(this.apiUrl, { code, language }); } -} \ No newline at end of file +}