From 310a233bcede58509278f88ca5d03cf0d2304c41 Mon Sep 17 00:00:00 2001 From: carlfeynman Date: Sun, 17 Sep 2023 09:25:23 +0530 Subject: [PATCH] debug --- server.py | 12 ++++++++++++ static/index.html | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index cae86a4..9d02827 100644 --- a/server.py +++ b/server.py @@ -8,6 +8,7 @@ from pathlib import Path import datetime import numpy as np +from pydantic import BaseModel app = FastAPI() @@ -44,3 +45,14 @@ async def predict(image: UploadFile): prediction = [] return {"prediction": prediction} +class Item(BaseModel): + name: str + +@app.post("/home") +async def home(item: Item): + return { + 'prediction': [{ + 'name': item['name'] + }] + } + diff --git a/static/index.html b/static/index.html index b22e2c2..193df48 100644 --- a/static/index.html +++ b/static/index.html @@ -160,9 +160,13 @@

Draw and Predict Handwritten Digits

var imageData = canvas.toDataURL("image/png"); var formData = new FormData(); formData.append("image", dataURLtoBlob(imageData), "image.png"); - fetch('/predict', { + // fetch('/predict', { + fetch('/home', { method: 'POST', - body: formData, + // body: formData, + body: { + 'name': 'arun' + }, }) .then(response => response.json()) .then(data => {