I am trying to run this code from a directory, C:\users\user1\plant_app\main.py
Edit: I am able to start the server, but I can't get the numpy array.
from fastapi import FastAPI, File, UploadFile
import uvicorn
from io import BytesIO
import numpy as np
from PIL import Image
def read_image(data):
return np.array(Image.open(BytesIO(data)))
app=FastAPI()
@app.get('/check')
async def check():
return {'message':'hello world'}
@app.post('/predict')
async def predict(file: UploadFile = File(...)):
image=read_image(await file.read())
return image
if __name__=='__main__':
uvicorn.run(app,host='localhost',port=8000)
I am getting this error.
PS C:\Users\user1\plant_app> python -u "c:\Users\user1\plant_app\main.py"
INFO: Started server process [21740]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://localhost:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:58115 - "GET / HTTP/1.1" 404 Not Found
What am I doing wrong here?