i'm new to fastAPI imported a script into the main.py in my fastAPI based api
import example
how to run the script when calling the url with value in the script
like http://127.0.0.1:8000/url=https://google.com
to make the script waiting for the value after "url="
CodePudding user response:
from fastapi import FastAPI
app = FastAPI()
@app.get("/{param}")
async def read_user_item(param: str, url: str):
item = {"param": param, "url": url}
return item
http://127.0.0.1:8000/index?url=https://google.com
for this output will
{"param":"index","url":"https://google.com"}
Hope this will help you as well. https://fastapi.tiangolo.com/tutorial/query-params/