api = fastapi.FastAPI()
@api.get('/api/sum')
def caculate(z):
if z == 0 :
return fastapi.Response(content = {'Error' : 'Z must be an integer'},
status_code=400,
media_type="application/json")
return
uvicorn.run(api, host="127.0.0.50", port=8000) #server
I am trying to return the response as mentioned in the content and a 400 http response. But it is giving me a 200 response and also giving me 'null' instead of the content.