Page 1 of 1

Wie übergebe ich eine URL als Pfadparameter an eine FastAPI-Route?

Posted: 13 Jan 2025, 19:22
by Guest
Ich habe mit FastAPI eine einfache API erstellt und versuche, eine URL als beliebigen Pfad-Parameter an eine FastAPI-Route zu übergeben.

Code: Select all

from fastapi import FastAPI
app = FastAPI()
@app.post("/{path}")
def pred_image(path:str):
print("path",path)
return {'path':path}
Wenn ich es teste, funktioniert es nicht und gibt einen Fehler aus. Ich teste es so:

Code: Select all

http://127.0.0.1:8000/https://raw.githubusercontent.com/ultralytics/yolov5/master/data/images/zidane.jpg