Skip to content

Instantly share code, notes, and snippets.

@lorenzojkrl
Created November 6, 2022 10:03
Show Gist options
  • Save lorenzojkrl/ddfa7dc43b3f196a0c7c7a4486267fa3 to your computer and use it in GitHub Desktop.
Save lorenzojkrl/ddfa7dc43b3f196a0c7c7a4486267fa3 to your computer and use it in GitHub Desktop.
DALLE - Initial code for React image generation app using openai API
function App() {
const [userPrompt, setUserPrompt] = useState("")
const [imageUrl, setImageUrl] = useState("")
return (
<div className="App">
{
imageUrl
? <img src={imageUrl} className="image" alt="ai thing" />
: <img src={logo} className="image" alt="logo" />
}
<p>Generate a unique image using DALL·E</p>
<p>What do you want to see?</p>
<input
placeholder='A sunset on the Sydney Opera House'
onChange={(e) => setUserPrompt(e.target.value)}
/>
<button>Generate</button>
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment