Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,76 +71,260 @@ async def Ingest(request:PPD):
|
|
| 71 |
async def static_page():
|
| 72 |
return """
|
| 73 |
<!DOCTYPE html>
|
| 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 |
</div>
|
| 106 |
-
<button onclick="submitData()">Send Payload</button>
|
| 107 |
-
<div id="response"></div>
|
| 108 |
</div>
|
| 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 |
"""
|
|
|
|
| 71 |
async def static_page():
|
| 72 |
return """
|
| 73 |
<!DOCTYPE html>
|
| 74 |
+
<html lang="en">
|
| 75 |
+
<head>
|
| 76 |
+
<meta charset="UTF-8">
|
| 77 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 78 |
+
<title>Pony Registration - Official Form</title>
|
| 79 |
+
<style>
|
| 80 |
+
/* US Govt Style Palette */
|
| 81 |
+
:root {
|
| 82 |
+
--primary-blue: #003366; /* Navy Blue */
|
| 83 |
+
--secondary-red: #d22027; /* Accent Red */
|
| 84 |
+
--bg-gray: #f0f0f0;
|
| 85 |
+
--border-gray: #5b616b;
|
| 86 |
+
--text-dark: #1b1b1b;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
body {
|
| 90 |
+
font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;
|
| 91 |
+
background: var(--bg-gray);
|
| 92 |
+
display: flex;
|
| 93 |
+
justify-content: center;
|
| 94 |
+
padding: 40px 20px;
|
| 95 |
+
color: var(--text-dark);
|
| 96 |
+
line-height: 1.5;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.form-container {
|
| 100 |
+
background: white;
|
| 101 |
+
padding: 40px;
|
| 102 |
+
border-top: 8px solid var(--primary-blue);
|
| 103 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
| 104 |
+
width: 100%;
|
| 105 |
+
max-width: 650px;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.header-section {
|
| 109 |
+
border-bottom: 2px solid #efefef;
|
| 110 |
+
margin-bottom: 25px;
|
| 111 |
+
padding-bottom: 15px;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
h2 {
|
| 115 |
+
color: var(--primary-blue);
|
| 116 |
+
margin: 0;
|
| 117 |
+
font-size: 28px;
|
| 118 |
+
text-transform: uppercase;
|
| 119 |
+
letter-spacing: 1px;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
.instruction-text {
|
| 123 |
+
font-size: 14px;
|
| 124 |
+
color: #555;
|
| 125 |
+
margin-top: 5px;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.grid {
|
| 129 |
+
display: grid;
|
| 130 |
+
grid-template-columns: 1fr 1fr;
|
| 131 |
+
gap: 20px;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
.field { margin-bottom: 20px; }
|
| 135 |
+
.full { grid-column: span 2; }
|
| 136 |
+
|
| 137 |
+
label {
|
| 138 |
+
display: block;
|
| 139 |
+
font-size: 14px;
|
| 140 |
+
font-weight: 700;
|
| 141 |
+
margin-bottom: 8px;
|
| 142 |
+
color: var(--text-dark);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
input[type="text"],
|
| 146 |
+
input[type="number"] {
|
| 147 |
+
width: 100%;
|
| 148 |
+
padding: 12px;
|
| 149 |
+
border: 1px solid var(--border-gray);
|
| 150 |
+
border-radius: 0; /* Govt forms often use sharp corners */
|
| 151 |
+
box-sizing: border-box;
|
| 152 |
+
font-size: 16px;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
input:focus {
|
| 156 |
+
outline: 3px solid #2491ff;
|
| 157 |
+
outline-offset: 0;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/* Checkbox styling */
|
| 161 |
+
.checkbox-group {
|
| 162 |
+
display: flex;
|
| 163 |
+
align-items: center;
|
| 164 |
+
gap: 10px;
|
| 165 |
+
cursor: pointer;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
input[type="checkbox"] {
|
| 169 |
+
width: 20px;
|
| 170 |
+
height: 20px;
|
| 171 |
+
cursor: pointer;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/* Buttons */
|
| 175 |
+
.button-row {
|
| 176 |
+
display: flex;
|
| 177 |
+
gap: 15px;
|
| 178 |
+
margin-top: 30px;
|
| 179 |
+
border-top: 1px solid #ddd;
|
| 180 |
+
padding-top: 20px;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
button {
|
| 184 |
+
flex: 2;
|
| 185 |
+
padding: 15px;
|
| 186 |
+
font-size: 16px;
|
| 187 |
+
font-weight: bold;
|
| 188 |
+
border: none;
|
| 189 |
+
cursor: pointer;
|
| 190 |
+
transition: background 0.2s;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
.btn-submit {
|
| 194 |
+
background: var(--primary-blue);
|
| 195 |
+
color: white;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.btn-submit:hover { background: #002244; }
|
| 199 |
+
|
| 200 |
+
.btn-clear {
|
| 201 |
+
flex: 1;
|
| 202 |
+
background: #e1e1e1;
|
| 203 |
+
color: #333;
|
| 204 |
+
border: 1px solid #ccc;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.btn-clear:hover { background: #d0d0d0; }
|
| 208 |
+
|
| 209 |
+
.required-star { color: var(--secondary-red); }
|
| 210 |
+
</style>
|
| 211 |
+
</head>
|
| 212 |
+
<body>
|
| 213 |
+
|
| 214 |
+
<div class="form-container">
|
| 215 |
+
<div class="header-section">
|
| 216 |
+
<h2>Pony Registration</h2>
|
| 217 |
+
<div class="instruction-text">Official Registration Form for Domesticated Equines. Please complete all required fields.</div>
|
| 218 |
+
</div>
|
| 219 |
+
|
| 220 |
+
<form id="registrationForm">
|
| 221 |
+
<div class="grid">
|
| 222 |
+
<div class="field full">
|
| 223 |
+
<label for="name">Full Legal Name <span class="required-star">*</span></label>
|
| 224 |
+
<input id="name" type="text" placeholder="e.g. John Doe">
|
| 225 |
+
</div>
|
| 226 |
+
|
| 227 |
+
<div class="field">
|
| 228 |
+
<label for="registration_number">Registration Number</label>
|
| 229 |
+
<input id="registration_number" type="text">
|
| 230 |
+
</div>
|
| 231 |
+
|
| 232 |
+
<div class="field">
|
| 233 |
+
<label for="phone_number">Phone Number</label>
|
| 234 |
+
<input id="phone_number" type="text" placeholder="(555) 000-0000">
|
| 235 |
+
</div>
|
| 236 |
+
|
| 237 |
+
<div class="field full">
|
| 238 |
+
<label for="address">Mailing Address</label>
|
| 239 |
+
<input id="address" type="text">
|
| 240 |
+
</div>
|
| 241 |
+
|
| 242 |
+
<div class="field">
|
| 243 |
+
<label for="aadhar">Aadhar / ID Number</label>
|
| 244 |
+
<input id="aadhar" type="text">
|
| 245 |
+
</div>
|
| 246 |
+
|
| 247 |
+
<div class="field">
|
| 248 |
+
<label for="parentage">Parentage / Lineage</label>
|
| 249 |
+
<input id="parentage" type="text">
|
| 250 |
+
</div>
|
| 251 |
+
|
| 252 |
+
<div class="field">
|
| 253 |
+
<label for="total_ponies">Total Quantity of Ponies</label>
|
| 254 |
+
<input type="number" id="total_ponies">
|
| 255 |
+
</div>
|
| 256 |
+
|
| 257 |
+
<div class="field">
|
| 258 |
+
<label for="stand">Assigned Stand</label>
|
| 259 |
+
<input id="stand" type="text">
|
| 260 |
+
</div>
|
| 261 |
+
|
| 262 |
+
<div class="field checkbox-group">
|
| 263 |
+
<input type="checkbox" id="license">
|
| 264 |
+
<label for="license" style="margin-bottom:0">Valid License Held</label>
|
| 265 |
+
</div>
|
| 266 |
+
|
| 267 |
+
<div class="field checkbox-group">
|
| 268 |
+
<input type="checkbox" id="renewal">
|
| 269 |
+
<label for="renewal" style="margin-bottom:0">Apply for Renewal</label>
|
| 270 |
</div>
|
|
|
|
|
|
|
| 271 |
</div>
|
| 272 |
|
| 273 |
+
<div class="button-row">
|
| 274 |
+
<button type="button" class="btn-clear" onclick="clearForm()">Clear Form</button>
|
| 275 |
+
<button type="button" class="btn-submit" onclick="submitData()">Submit Application</button>
|
| 276 |
+
</div>
|
| 277 |
+
</form>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<script>
|
| 281 |
+
async function submitData() {
|
| 282 |
+
const payload = {
|
| 283 |
+
"name": document.getElementById('name').value,
|
| 284 |
+
"registration_number": document.getElementById('registration_number').value,
|
| 285 |
+
"phone_number": document.getElementById('phone_number').value,
|
| 286 |
+
"address": document.getElementById('address').value,
|
| 287 |
+
"aadhar": document.getElementById('aadhar').value,
|
| 288 |
+
"parentage": document.getElementById('parentage').value,
|
| 289 |
+
"total_ponies": document.getElementById('total_ponies').value,
|
| 290 |
+
"stand": document.getElementById('stand').value,
|
| 291 |
+
"license": document.getElementById('license').checked,
|
| 292 |
+
"renewal": document.getElementById('renewal').checked
|
| 293 |
+
};
|
| 294 |
+
|
| 295 |
+
// Basic validation check
|
| 296 |
+
if(!payload.name) {
|
| 297 |
+
alert("Official Error: Full Name is a required field.");
|
| 298 |
+
return;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
try {
|
| 302 |
+
const res = await fetch('/dataingestion', {
|
| 303 |
+
method: 'POST',
|
| 304 |
+
headers: {'Content-Type': 'application/json'},
|
| 305 |
+
body: JSON.stringify(payload)
|
| 306 |
+
});
|
| 307 |
+
|
| 308 |
+
const result = await res.json();
|
| 309 |
+
if(result.success === true){
|
| 310 |
+
alert("Submission Successful: Data has been transmitted.");
|
| 311 |
+
} else {
|
| 312 |
+
alert("Error: The server could not process your application.");
|
| 313 |
}
|
| 314 |
+
} catch (error) {
|
| 315 |
+
console.error("Transmission error:", error);
|
| 316 |
+
alert("Network Error: Could not connect to official servers.");
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
function clearForm() {
|
| 321 |
+
if(confirm("Are you sure you want to clear all entered data?")) {
|
| 322 |
+
document.getElementById("registrationForm").reset();
|
| 323 |
+
}
|
| 324 |
+
}
|
| 325 |
+
</script>
|
| 326 |
+
|
| 327 |
+
</body>
|
| 328 |
+
</html>
|
| 329 |
+
|
| 330 |
"""
|