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) { } // Function to send the topic and difficulty level to the backend and get the generated content generateContent(topic: string, difficulty: string): Observable { return this.http.post(`${this.baseUrl}/generate_content`, { topic, difficulty }); } generateQuestions(content: string, difficulty: string): Observable { return this.http.post(`${this.baseUrl}/generate_questions`, { content, difficulty }); } validateAnswer(question: any, selected_answer: string): Observable { return this.http.post(`${this.baseUrl}/validate_answer`, { question: question, selected_answer: selected_answer }); } }