-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
108 lines (100 loc) · 3.31 KB
/
index.html
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Travel Itinerary Optimizer</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
.container {
max-width: 800px;
margin: auto;
background: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
}
label {
display: block;
margin-top: 10px;
}
input[type="text"], input[type="number"], textarea {
width: 100%;
padding: 8px;
margin-top: 5px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin-top: 20px;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
white-space: pre-wrap;
}
</style>
</head>
<body>
<div class="container">
<h1>Travel Itinerary Optimizer</h1>
<form id="itineraryForm">
<label for="destinations">Destinations (comma-separated):</label>
<input type="text" id="destinations" required>
<label for="preferences">Preferences:</label>
<textarea id="preferences" required></textarea>
<label for="budget">Budget ($):</label>
<input type="number" id="budget" required>
<button type="submit">Generate Itinerary</button>
</form>
<div id="result"></div>
</div>
<script>
document.getElementById('itineraryForm').addEventListener('submit', async (e) => {
e.preventDefault();
const destinations = document.getElementById('destinations').value.split(',').map(d => d.trim());
const preferences = document.getElementById('preferences').value;
const budget = document.getElementById('budget').value;
const resultDiv = document.getElementById('result');
resultDiv.textContent = 'Generating itinerary...';
try {
const response = await fetch('/optimize-itinerary', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ destinations, preferences, budget }),
});
const data = await response.json();
if (response.ok) {
resultDiv.textContent = data.itinerary;
} else {
resultDiv.textContent = `Error: ${data.error}`;
}
} catch (error) {
resultDiv.textContent = `Error: ${error.message}`;
}
});
</script>
</body>
</html>