carlfeynman commited on
Commit
652d2d6
1 Parent(s): bc122c3
Files changed (2) hide show
  1. server.py +1 -1
  2. static/index.html +6 -3
server.py CHANGED
@@ -52,7 +52,7 @@ class Item(BaseModel):
52
  async def home(item: Item):
53
  return {
54
  'prediction': [{
55
- 'name': item['name']
56
  }]
57
  }
58
 
 
52
  async def home(item: Item):
53
  return {
54
  'prediction': [{
55
+ 'name': item.name
56
  }]
57
  }
58
 
static/index.html CHANGED
@@ -164,11 +164,14 @@
164
  fetch('/home', {
165
  method: 'POST',
166
  // body: formData,
167
- body: {
 
 
 
168
  'item': {
169
  'name': 'arun'
170
  }
171
- },
172
  })
173
  .then(response => response.json())
174
  .then(data => {
@@ -206,7 +209,7 @@
206
  })
207
  .catch(error => {
208
  console.error('Error:', error);
209
- predictionResult.textContent = 'Something wentr wrong, try again.';
210
  captureButton.disabled = false
211
  captureButton.style.opacity = "1";
212
  captureButton.innerText = 'Predict'
 
164
  fetch('/home', {
165
  method: 'POST',
166
  // body: formData,
167
+ headers: {
168
+ 'Content-Type': 'application/json', // Set the Content-Type header
169
+ },
170
+ body: JSON.stringify({
171
  'item': {
172
  'name': 'arun'
173
  }
174
+ })
175
  })
176
  .then(response => response.json())
177
  .then(data => {
 
209
  })
210
  .catch(error => {
211
  console.error('Error:', error);
212
+ predictionResult.textContent = 'Something went wrong, try again.';
213
  captureButton.disabled = false
214
  captureButton.style.opacity = "1";
215
  captureButton.innerText = 'Predict'