from fastapi import FastAPI import requests import json url = "http://127.0.0.1:5000/translate" data = { "q": "Hello i m here", "source": "auto", "target": "en", "format": "text", "alternatives": 3, "api_key": "" } headers = { "Content-Type": "application/json" } app = FastAPI() # Making the POST request response = requests.post(url, json=data, headers=headers) # Handling the response if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code} - {response.reason}") @app.get("/") def greet_json(): # Making the POST request response = requests.post(url, json=data, headers=headers) # Handling the response if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code} - {response.reason}") return {"Hello": "World!"}