Set Up OpenAI API: Add your OpenAI API key configuration in the code.
python
openai.api_key = 'YOUR_API_KEY'
Run the Application
bash
python app.py
Send Request to Generate Art: Use Postman or curl to send a POST request to http://127.0.0.1:5000/generate_art, including the user description and selected style in the request body.
json
"description": "A serene sunset over the mountains.",
"style": "Impressionism"
}
Retrieve Artworks: Send a GET request to http://127.0.0.1:5000/artworks to get all generated artworks.
Notes
This example creates an SQLite database to store generated artworks, supporting real-time updates.
You can expand the options for art styles as needed.
Make sure the code runs in an appropriate environment with the required libraries configured.