Hello,
I have trouble understanding how to implement a web application using Stralette in lesson2. I see the code in the lesson but I do not know where to implement this code? is this in a cell of the notebook? is there a good tutorial in using Starlette?
here is the code in the lesson I am refering to,
So you might create a route something like this (thanks to Simon Willison for the structure of this code):
* *@app.route("/classify-url", methods=["GET"])async def classify_url(request): bytes = await get_bytes(request.query_params["url"]) img = open_image(BytesIO(bytes)) _,_,losses = learner.predict(img) return JSONResponse({ "predictions": sorted( zip(cat_learner.data.classes, map(float, losses)), key=lambda p: p[1], reverse=True ) })* *