I am trying to show weather of a specific city but am unable to execute the program. I am using Fastapi. I also included the BaseModel in the solution but still it is not working. What am I doing wrong?
from fastapi import FastAPI, requests
from pydantic import BaseModel
app = FastAPI()
class Data(BaseModel):
user: str
@app.get("/task1")
def task1(re1: Data):
re1= requests.get('http://api.openweathermap.org/data/2.5/weather?q=London,uk&appictualappidd=a')
z = re1.txt
return z
Command to initiate the server:
uvicorn task:app --host "0.0.0.0" --port 8000 --reload
Output in Browser:
{"detail":"Not Found"}
I was expecting the returned data from the api on browser's screen but am instead getting an error.