Oviya
commited on
Commit
·
0759111
1
Parent(s):
2a76f2a
reding component
Browse files
src/app/generate-questions/generate-questions.service.ts
CHANGED
|
@@ -17,8 +17,7 @@ export class GenerateQuestionsService {
|
|
| 17 |
// Method to get questions from the backend
|
| 18 |
generateQuestions(topic: string, difficulty: string): Observable<any> {
|
| 19 |
return this.http.post<any>(`${this.baseUrl}/generate-questions`, { topic, difficulty });
|
| 20 |
-
|
| 21 |
-
}
|
| 22 |
|
| 23 |
|
| 24 |
|
|
|
|
| 17 |
// Method to get questions from the backend
|
| 18 |
generateQuestions(topic: string, difficulty: string): Observable<any> {
|
| 19 |
return this.http.post<any>(`${this.baseUrl}/generate-questions`, { topic, difficulty });
|
| 20 |
+
}
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
|
src/app/reading/reading.service.ts
CHANGED
|
@@ -7,24 +7,27 @@ import { Observable } from 'rxjs';
|
|
| 7 |
})
|
| 8 |
export class ReadingService {
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
private apiUrl = 'http://127.0.0.1:5001/generate_content';
|
| 12 |
-
private apiUrlQuestions = 'http://127.0.0.1:5001/generate_questions'; // Backend API URL for questions
|
| 13 |
-
private apiUrlValidateAnswer = 'http://127.0.0.1:5001/validate_answer'; // Backend API URL for validating answers
|
| 14 |
|
| 15 |
constructor(private http: HttpClient) { }
|
| 16 |
|
| 17 |
// Function to send the topic and difficulty level to the backend and get the generated content
|
| 18 |
generateContent(topic: string, difficulty: string): Observable<any> {
|
| 19 |
-
return this.http.post<any>(this.
|
| 20 |
}
|
| 21 |
|
| 22 |
generateQuestions(content: string, difficulty: string): Observable<any> {
|
| 23 |
-
return this.http.post<any>(this.
|
| 24 |
}
|
| 25 |
|
| 26 |
validateAnswer(question: any, selected_answer: string): Observable<any> {
|
| 27 |
-
return this.http.post<any>(this.
|
| 28 |
question: question,
|
| 29 |
selected_answer: selected_answer
|
| 30 |
});
|
|
|
|
| 7 |
})
|
| 8 |
export class ReadingService {
|
| 9 |
|
| 10 |
+
private baseUrl = location.hostname.endsWith('hf.space')
|
| 11 |
+
? 'https://pykara-py-learn-backend.hf.space/media'
|
| 12 |
+
: 'http://localhost:5000/media';
|
| 13 |
|
| 14 |
+
//private apiUrl = 'http://127.0.0.1:5001/generate_content';
|
| 15 |
+
//private apiUrlQuestions = 'http://127.0.0.1:5001/generate_questions'; // Backend API URL for questions
|
| 16 |
+
//private apiUrlValidateAnswer = 'http://127.0.0.1:5001/validate_answer'; // Backend API URL for validating answers
|
| 17 |
|
| 18 |
constructor(private http: HttpClient) { }
|
| 19 |
|
| 20 |
// Function to send the topic and difficulty level to the backend and get the generated content
|
| 21 |
generateContent(topic: string, difficulty: string): Observable<any> {
|
| 22 |
+
return this.http.post<any>(`${this.baseUrl}/generate_content`, { topic, difficulty });
|
| 23 |
}
|
| 24 |
|
| 25 |
generateQuestions(content: string, difficulty: string): Observable<any> {
|
| 26 |
+
return this.http.post<any>(`${this.baseUrl}/generate_questions`, { content, difficulty });
|
| 27 |
}
|
| 28 |
|
| 29 |
validateAnswer(question: any, selected_answer: string): Observable<any> {
|
| 30 |
+
return this.http.post<any>(`${this.baseUrl}/validate_answer`, {
|
| 31 |
question: question,
|
| 32 |
selected_answer: selected_answer
|
| 33 |
});
|