Junaidb commited on
Commit
4c237dc
·
verified ·
1 Parent(s): 8edb4d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +252 -68
app.py CHANGED
@@ -71,76 +71,260 @@ async def Ingest(request:PPD):
71
  async def static_page():
72
  return """
73
  <!DOCTYPE html>
74
- <html>
75
- <head>
76
- <title>Manual Data Entry</title>
77
- <style>
78
- body { font-family: 'Segoe UI', sans-serif; background: #f0f2f5; display: flex; justify-content: center; padding: 20px; }
79
- .card { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 100%; max-width: 500px; }
80
- h2 { color: #1c1e21; margin-top: 0; }
81
- .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
82
- .field { margin-bottom: 15px; }
83
- .full { grid-column: span 2; }
84
- label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 5px; color: #606770; text-transform: uppercase; }
85
- input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; }
86
- button { width: 100%; padding: 12px; background: #0084ff; color: white; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; margin-top: 10px; }
87
- button:hover { background: #0073e6; }
88
- #response { margin-top: 15px; padding: 10px; border-radius: 4px; display: none; }
89
- </style>
90
- </head>
91
- <body>
92
- <div class="card">
93
- <h2>Pony Registration</h2>
94
- <div class="grid">
95
- <div class="field full"><label>Full Name</label><input id="name"></div>
96
- <div class="field"><label>Reg Number</label><input id="registration_number"></div>
97
- <div class="field"><label>Phone</label><input id="phone_number"></div>
98
- <div class="field full"><label>Address</label><input id="address"></div>
99
- <div class="field"><label>Aadhar</label><input id="aadhar"></div>
100
- <div class="field"><label>Parentage</label><input id="parentage"></div>
101
- <div class="field"><label>Total Ponies</label><input type="number" id="total_ponies"></div>
102
- <div class="field"><label>Stand</label><input id="stand"></div>
103
- <div class="field"><label>License</label><input type="checkbox" id="license"></div>
104
- <div class="field"><label>Renewal</label><input type="checkbox" id="renewal"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  </div>
106
- <button onclick="submitData()">Send Payload</button>
107
- <div id="response"></div>
108
  </div>
109
 
110
- <script>
111
- async function submitData() {
112
- const payload = {
113
- "name": document.getElementById('name').value,
114
- "registration_number": document.getElementById('registration_number').value,
115
- "phone_number": document.getElementById('phone_number').value,
116
- "address": document.getElementById('address').value,
117
- "aadhar": document.getElementById('aadhar').value,
118
- "parentage": document.getElementById('parentage').value,
119
- "total_ponies": document.getElementById('total_ponies').value,
120
- "stand": document.getElementById('stand').value,
121
- "license": document.getElementById('license').checked,
122
- "renewal": document.getElementById('renewal').checked
123
- };
124
-
125
- const res = await fetch('/dataingestion', {
126
- method: 'POST',
127
- headers: {'Content-Type': 'application/json'},
128
- body: JSON.stringify(payload)
129
- });
130
-
131
- const result = await res.json();
132
- if(result.success==true){
133
- alert("done")
134
- }
135
- else {
136
- alert("error")
137
- }
138
- //const respDiv = document.getElementById('response');
139
- //respDiv.style.display = 'block';
140
- //respDiv.style.background = res.ok ? '#e7f3ff' : '#ffebe9';
141
- //respDiv.innerText = res.ok ? "Success: " + result.received_id : "Error sending data";
 
 
 
 
 
 
 
 
142
  }
143
- </script>
144
- </body>
145
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  """