Spaces:
Configuration error

py-match / src /app /api.service.ts
pykara's picture
Upload 5840 files
38fa174 verified
Raw History Blame Contribute Delete
852 Bytes
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<any>(`${this.base}/q/start`, body);
}
next(session_id: string, selected_color: 'blue' | 'green' | 'red' | 'yellow') {
return this.http.post<any>(`${this.base}/q/next`, { session_id, selected_color });
}
}