import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { environment } from '../environments/environment'; @Injectable({ providedIn: 'root' }) export class ApiService { // Decide backend base URL at runtime private readonly base = location.hostname.endsWith('hf.space') ? 'https://pykara-py-match-backend.hf.space' : 'http://localhost:5000'; // Local Flask backend //private base = environment.apiBase; constructor(private http: HttpClient) { } start(body = { n_questions: 10, batch_size: 5, domain: 'marriage' }) { return this.http.post(`${this.base}/q/start`, body); } next(session_id: string, selected_color: 'blue' | 'green' | 'red' | 'yellow') { return this.http.post(`${this.base}/q/next`, { session_id, selected_color }); } }