File size: 852 Bytes
38fa174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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 });
  }
}