init commit, input data parsing logic and page

This commit is contained in:
jaehwang committed 2025-08-19 13:08:28 +09:00
commit a60d49ae92
12 files changed
+1262

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>부동산 검색 - 자연어 분석</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<div class="container">
<header>
<h1>🏠 부동산 자연어 검색</h1>
<p>원하시는 부동산 조건을 자유롭게 입력해주세요</p>
</header>
<main>
<div class="search-section">
<textarea id="searchInput" placeholder="예: 강남역 근처 전세 2억 이하 투룸 찾아줘
서초동 30평대 아파트 매매 10억 이하
방 3개짜리 월세 100/50 이하 판교"></textarea>
<button id="searchBtn" onclick="parseQuery()">분석하기</button>
</div>
<div class="examples">
<h3>입력 예시:</h3>
<div class="example-chips">
<span class="chip" onclick="setExample(this)">강남 전세 3억 방 2개</span>
<span class="chip" onclick="setExample(this)">판교 30평 아파트 매매</span>
<span class="chip" onclick="setExample(this)">서초동 월세 200/100</span>
</div>
</div>
<div id="resultSection" class="result-section" style="display: none;">
<h2>📊 분석 결과</h2>
<div id="resultContent"></div>
</div>
<div id="loadingSection" class="loading" style="display: none;">
<div class="spinner"></div>
<p>AI가 분석 중입니다...</p>
</div>
</main>
</div>
<script src="/static/script.js"></script>
</body>
</html>
+97
View File
@@ -0,0 +1,97 @@
// 예시 텍스트 설정
function setExample(element) {
document.getElementById('searchInput').value = element.textContent;
}
// 쿼리 파싱 및 분석
async function parseQuery() {
const input = document.getElementById('searchInput').value.trim();
if (!input) {
alert('검색할 내용을 입력해주세요!');
return;
}
// UI 상태 변경
document.getElementById('loadingSection').style.display = 'block';
document.getElementById('resultSection').style.display = 'none';
document.getElementById('searchBtn').disabled = true;
try {
const response = await fetch('/api/parse', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: input })
});
if (!response.ok) {
throw new Error('서버 오류가 발생했습니다.');
}
const data = await response.json();
displayResults(data);
} catch (error) {
alert('오류: ' + error.message);
console.error('Error:', error);
} finally {
document.getElementById('loadingSection').style.display = 'none';
document.getElementById('searchBtn').disabled = false;
}
}
// 결과 표시
function displayResults(data) {
const resultContent = document.getElementById('resultContent');
let html = '';
if (data.transaction_type) {
html += `<div class="result-item">
<strong>거래 유형:</strong> ${data.transaction_type}
</div>`;
}
if (data.price) {
html += `<div class="result-item">
<strong>가격:</strong> ${data.price}
</div>`;
}
if (data.location) {
html += `<div class="result-item">
<strong>위치:</strong> ${data.location}
</div>`;
}
if (data.area) {
html += `<div class="result-item">
<strong>면적:</strong> ${data.area}
</div>`;
}
if (data.rooms) {
html += `<div class="result-item">
<strong>방 개수:</strong> ${data.rooms}
</div>`;
}
if (!html) {
html = '<p>추출된 정보가 없습니다. 더 구체적으로 입력해주세요.</p>';
}
resultContent.innerHTML = html;
document.getElementById('resultSection').style.display = 'block';
}
// Enter 키로 검색
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('searchInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
parseQuery();
}
});
});
+152
View File
@@ -0,0 +1,152 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container {
width: 90%;
max-width: 800px;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
padding: 40px;
}
header {
text-align: center;
margin-bottom: 30px;
}
header h1 {
color: #333;
font-size: 2.5em;
margin-bottom: 10px;
}
header p {
color: #666;
font-size: 1.1em;
}
.search-section {
margin-bottom: 30px;
}
#searchInput {
width: 100%;
min-height: 120px;
padding: 15px;
font-size: 16px;
border: 2px solid #e0e0e0;
border-radius: 10px;
resize: vertical;
font-family: inherit;
transition: border-color 0.3s;
}
#searchInput:focus {
outline: none;
border-color: #667eea;
}
#searchBtn {
width: 100%;
padding: 15px;
margin-top: 15px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 10px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: transform 0.2s;
}
#searchBtn:hover {
transform: translateY(-2px);
}
.examples {
margin-bottom: 30px;
}
.examples h3 {
color: #555;
margin-bottom: 10px;
}
.example-chips {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.chip {
background: #f0f0f0;
padding: 8px 16px;
border-radius: 20px;
cursor: pointer;
transition: all 0.3s;
}
.chip:hover {
background: #667eea;
color: white;
}
.result-section {
background: #f8f9fa;
padding: 25px;
border-radius: 15px;
margin-top: 30px;
}
.result-section h2 {
color: #333;
margin-bottom: 20px;
}
.result-item {
background: white;
padding: 15px;
border-radius: 10px;
margin-bottom: 15px;
border-left: 4px solid #667eea;
}
.result-item strong {
color: #667eea;
display: inline-block;
width: 100px;
}
.loading {
text-align: center;
padding: 40px;
}
.spinner {
width: 50px;
height: 50px;
border: 5px solid #f3f3f3;
border-top: 5px solid #667eea;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 20px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}