-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.html
More file actions
158 lines (144 loc) · 5.67 KB
/
test-api.html
File metadata and controls
158 lines (144 loc) · 5.67 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Test Page</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.test-section {
background: white;
margin: 20px 0;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
margin: 5px;
}
button:hover {
background: #0056b3;
}
pre {
background: #f8f9fa;
padding: 15px;
border-radius: 4px;
overflow-x: auto;
white-space: pre-wrap;
}
.error {
color: #dc3545;
background: #f8d7da;
padding: 10px;
border-radius: 4px;
}
.success {
color: #155724;
background: #d4edda;
padding: 10px;
border-radius: 4px;
}
</style>
</head>
<body>
<h1>🧪 Flexlink API Test Page</h1>
<div class="test-section">
<h2>Backend API Status</h2>
<button onclick="testBackendConnection()">Test Backend Connection</button>
<div id="backend-status"></div>
</div>
<div class="test-section">
<h2>Movie Cinemas API</h2>
<button onclick="testMovieCinemas()">Get Movie Cinemas</button>
<div id="cinema-results"></div>
</div>
<div class="test-section">
<h2>Concert Artists API</h2>
<button onclick="testConcertArtists()">Get Concert Artists</button>
<div id="artist-results"></div>
</div>
<div class="test-section">
<h2>Flight Search API</h2>
<button onclick="testFlightSearch()">Search Flights (LOS to ABV)</button>
<div id="flight-results"></div>
</div>
<script>
const API_BASE_URL = 'http://localhost:8001';
async function testBackendConnection() {
const statusDiv = document.getElementById('backend-status');
statusDiv.innerHTML = '<p>Testing connection...</p>';
try {
const response = await fetch(`${API_BASE_URL}/docs`);
if (response.ok) {
statusDiv.innerHTML = '<div class="success">✅ Backend is running! API docs are accessible.</div>';
} else {
statusDiv.innerHTML = '<div class="error">❌ Backend responded but with error status: ' + response.status + '</div>';
}
} catch (error) {
statusDiv.innerHTML = '<div class="error">❌ Cannot connect to backend: ' + error.message + '</div>';
}
}
async function testMovieCinemas() {
const resultsDiv = document.getElementById('cinema-results');
resultsDiv.innerHTML = '<p>Loading cinemas...</p>';
try {
const response = await fetch(`${API_BASE_URL}/api/ticketing/movies/cinemas`);
if (response.ok) {
const data = await response.json();
resultsDiv.innerHTML = '<div class="success">✅ Success!</div><pre>' + JSON.stringify(data, null, 2) + '</pre>';
} else {
resultsDiv.innerHTML = '<div class="error">❌ Error: ' + response.status + '</div>';
}
} catch (error) {
resultsDiv.innerHTML = '<div class="error">❌ Error: ' + error.message + '</div>';
}
}
async function testConcertArtists() {
const resultsDiv = document.getElementById('artist-results');
resultsDiv.innerHTML = '<p>Loading artists...</p>';
try {
const response = await fetch(`${API_BASE_URL}/api/ticketing/concerts/artists`);
if (response.ok) {
const data = await response.json();
resultsDiv.innerHTML = '<div class="success">✅ Success!</div><pre>' + JSON.stringify(data, null, 2) + '</pre>';
} else {
resultsDiv.innerHTML = '<div class="error">❌ Error: ' + response.status + '</div>';
}
} catch (error) {
resultsDiv.innerHTML = '<div class="error">❌ Error: ' + error.message + '</div>';
}
}
async function testFlightSearch() {
const resultsDiv = document.getElementById('flight-results');
resultsDiv.innerHTML = '<p>Searching flights...</p>';
try {
const response = await fetch(`${API_BASE_URL}/api/ticketing/flights/search?origin=LOS&destination=ABV&date=2025-07-31`);
if (response.ok) {
const data = await response.json();
resultsDiv.innerHTML = '<div class="success">✅ Success!</div><pre>' + JSON.stringify(data, null, 2) + '</pre>';
} else {
resultsDiv.innerHTML = '<div class="error">❌ Error: ' + response.status + '</div>';
}
} catch (error) {
resultsDiv.innerHTML = '<div class="error">❌ Error: ' + error.message + '</div>';
}
}
// Auto-test connection on page load
window.onload = function() {
testBackendConnection();
}
</script>
</body>
</html>