웹 프론트 페이지 개발

- React + Vite 구성
 - lotto-frontend 구성
 - script 설정으로 nas server로 빌드 n 배포 수행
This commit is contained in:
2026-01-18 09:07:01 +09:00
parent eade32f58a
commit cb4978fe4a
13 changed files with 3902 additions and 0 deletions

39
src/api.js Normal file
View File

@@ -0,0 +1,39 @@
// src/api.js
export async function apiGet(path) {
const res = await fetch(path, { headers: { "Accept": "application/json" } });
if (!res.ok) {
const text = await res.text().catch(() => "");
throw new Error(`HTTP ${res.status} ${res.statusText}: ${text}`);
}
return res.json();
}
export async function apiDelete(path) {
const res = await fetch(path, { method: "DELETE" });
if (!res.ok) {
const text = await res.text().catch(() => "");
throw new Error(`HTTP ${res.status} ${res.statusText}: ${text}`);
}
return res.json();
}
export function getLatest() {
return apiGet("/api/lotto/latest");
}
export function recommend(params) {
const qs = new URLSearchParams({
recent_window: String(params.recent_window),
recent_weight: String(params.recent_weight),
avoid_recent_k: String(params.avoid_recent_k),
});
return apiGet(`/api/lotto/recommend?${qs.toString()}`);
}
export function getHistory(limit = 30) {
return apiGet(`/api/history?limit=${limit}`);
}
export function deleteHistory(id) {
return apiDelete(`/api/history/${id}`);
}