seo / app.py
Love2021's picture
Update app.py
d7519e7 verified
raw
history blame contribute delete
758 Bytes
from fastapi import FastAPI, HTTPException
import requests
app = FastAPI()
@app.get("/")
def greet_json():
url = "https://seoroast.co/api/generate-youtube-titles"
headers = {
"Content-Type": "application/json",
"origin": "https://seoroast.co",
"accept": "*/*"
}
payload = {
"content": "A Car Experiment",
"model": "google/gemini-flash-1.5",
"tone": "auto"
}
try:
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status() # Raise an error for bad responses
return response.json() # Return the entire JSON response
except requests.exceptions.RequestException as e:
raise HTTPException(status_code=500, detail=str(e))