|
|
import { Injectable } from '@angular/core'; |
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
import { Observable } from 'rxjs'; |
|
|
|
|
|
@Injectable({ |
|
|
providedIn: 'root' |
|
|
}) |
|
|
export class ReadingService { |
|
|
|
|
|
private baseUrl = location.hostname.endsWith('hf.space') |
|
|
? 'https://pykara-py-learn-backend.hf.space/media' |
|
|
: 'http://localhost:5000/media'; |
|
|
|
|
|
constructor(private http: HttpClient) { } |
|
|
|
|
|
|
|
|
generateContent(topic: string, difficulty: string): Observable<any> { |
|
|
return this.http.post<any>(`${this.baseUrl}/generate_content`, { topic, difficulty }); |
|
|
} |
|
|
|
|
|
generateQuestions(content: string, difficulty: string): Observable<any> { |
|
|
return this.http.post<any>(`${this.baseUrl}/generate_questions`, { content, difficulty }); |
|
|
} |
|
|
|
|
|
validateAnswer(question: any, selected_answer: string): Observable<any> { |
|
|
return this.http.post<any>(`${this.baseUrl}/validate_answer`, { |
|
|
question: question, |
|
|
selected_answer: selected_answer |
|
|
}); |
|
|
} |
|
|
} |
|
|
|