Junaidb commited on
Commit
32c9d19
·
verified ·
1 Parent(s): 092327b

Update app.py

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