Javier Buitrago
08/16/2023, 10:09 PMNate
08/16/2023, 10:50 PMhttpx
import httpx
from prefect import flow, task
@task
def http_request(method, url, **kwargs):
with httpx.Client() as client:
response = client.request(method, url, **kwargs)
return response.json()
@flow(log_prints=True)
def web_flow():
data = http_request("GET", "<https://jsonplaceholder.typicode.com/todos/1>")
print(data)
if __name__ == "__main__":
web_flow()
Javier Buitrago
08/16/2023, 11:25 PMNate
08/16/2023, 11:28 PMfetch API datasomething specific you're talking about or do you just mean fetching data from some API? if the latter, you could replace the
httpx
call with a call to your API of interestJavier Buitrago
08/16/2023, 11:35 PMNate
08/16/2023, 11:36 PMJavier Buitrago
08/17/2023, 12:25 AM