# podplot_backend/main.py
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import openai
import os
app = FastAPI()
openai.api_key = os.getenv("OPENAI_API_KEY")
class OutlineRequest(BaseModel):
topic: str
style: str
@app.post("/api/generate_outline")
async def generate_outline(req: OutlineRequest):
prompt = (
f"Generate a podcast episode outline for the topic '{req.topic}' in the style '{req.style}'. "
"Include:\n- Episode title\n- Segment breakdown (intro, main content, outro)\n"
"- Suggested discussion points\n- CTA ideas (like 'rate and subscribe')"
)
try:
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt}],
max_tokens=500,
temperature=0.7,
)
outline = response.choices[0].message.content.strip()
return {"outline": outline}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
// src/App.jsx
import React, { useState } from "react";
import "./App.css";
function App() {
const [topic, setTopic] = useState("");
const [style, setStyle] = useState("Interview");
const [outline, setOutline] = useState("");
const [loading, setLoading] = useState(false);
const handleSubmit = async (e) => {
e.preventDefault();
setLoading(true);
setOutline("");
const res = await fetch("/api/generate_outline", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ topic, style }),
});
const data = await res.json();
setOutline(data.outline);
setLoading(false);
};