Last active
February 11, 2023 05:35
-
-
Save mrtushartiwari/7dc2358bc4550ae9cd1ededdf60c54ad to your computer and use it in GitHub Desktop.
FastAPI intercommunication caller method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
import requests | |
import json | |
host = '0.0.0.0:8001' # diffent API running | |
app = FastAPI() | |
@app.get("/goodname") | |
async def root(): | |
""" | |
Just call an post API and return its response with some added compliment | |
""" | |
name_url= f"http://{host}/coolname" | |
full_name = {"first_name": "Tushar", "last_name": "Tiwari"} | |
name_response = requests.post(name_url , json=full_name) | |
print(name_response) | |
compliment_str = json.loads(name_response.content) + ". It even suits your personality." | |
return compliment_str # name_response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment