0

I want to send data from app.post() to app.get()

@app.get("/predict", response_class=HTMLResponse)
async def get_predict(request: Request):
    return templates.TemplateResponse("predict.html", {"request": request})

@app.post("/predict", response_class=HTMLResponse)
async def predict(
    request: Request,
    mintempC: float = Form(...),
    maxtempC: float = Form(...),
    humidity: float = Form(...),
    DewPointC: float = Form(...),
    pressure: float = Form(...),
    cloudcover: float = Form(...),
    visibility: float = Form(...),
    precipMM: float = Form(...),
    city :    int = Form(...),  
    raintoday: int = Form(...),
):
    
    pred = model.predict([[maxtempC, mintempC, DewPointC, cloudcover, humidity, pressure, visibility, precipMM, city, raintoday]])[0]
    output = pred
    if output == 0:
        return templates.TemplateResponse("after_sunny.html", {"request": request})
    else:
        return templates.TemplateResponse("after_rainy.html", {"request": request})

im getting the error starlette.routing.NoMatchFound: No route exists for name "static" and params "filename".

Jay Nila
  • 1
  • 1
  • Does [this](https://stackoverflow.com/a/71665594/17865804) answer your question? – Chris Sep 02 '23 at 12:29
  • If not, please provide a [mre]. Please edit your question and the code of your templates as well (just what is needed to reproduce the error). You should also instantiate `templates` as denonstrated in the example given in the link above – Chris Sep 02 '23 at 12:30
  • Also, please have a look at [this answer](https://stackoverflow.com/a/73088816/17865804), regarding `starlette.routing.NoMatchFound` error. – Chris Sep 02 '23 at 12:31

0 Answers0