简体   繁体   中英

How can I pass a URL as a parameter in get with FastAPI?

For example, I have this URL

https://store.epicgames.com/es-ES/p/dead-island-2--gold-edition

async def read_CI(CI: str):
    return{"CI_Datos":CI}```

This is my curl

```curl -X 'GET' \
  'http://127.0.0.1:8000/Datos/%2F%2F' \
  -H 'accept: application/json' 

and I want the API to be able to get that URL.

I get error 404 when I want to pass a URL. I understand that the problem is the //

After a little research, I have a solution:


@app.get("/Datos")
async def get_url(
    url: str = None
):
    return {"url": url}


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM