Skip to content

Instantly share code, notes, and snippets.

@mrtushartiwari
Last active February 11, 2023 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrtushartiwari/7dc2358bc4550ae9cd1ededdf60c54ad to your computer and use it in GitHub Desktop.
Save mrtushartiwari/7dc2358bc4550ae9cd1ededdf60c54ad to your computer and use it in GitHub Desktop.
FastAPI intercommunication caller method
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