This project is a Flask-based API designed to process story data, generate visual descriptions, and create images using the MidJourney API. It integrates various custom modules for story generation, visual description configuration, and image prompt generation. The generated images are posted to a webhook and stored in a SQLite database.
-
Clone the repository:
git clone https://github.com/your-username/story-image-generator.git cd story-image-generator
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the project root and add the following:FLASK_APP=app.py FLASK_ENV=development MID_API_KEY=your_midjourney_api_key
-
Initialize the database:
flask db init flask db migrate flask db upgrade
-
Run the Flask application:
flask run
-
API Endpoints:
-
Process a Story:
POST /process-story
Request Body:
{ "tripettoId": "unique_tripetto_id", "order": "...", "story_configuration": "...", "visual_configuration": "..." }
-
Get Story Data:
GET /get-story-data/<tripetto_id>
Response:
{ "tripettoId": "unique_tripetto_id", "order": "...", "story_configuration": "...", "visual_configuration": "...", "story": "...", "image_urls": "..." }
-
The application uses Python's built-in logging module to log information, warnings, and errors. Logs are displayed in the console.
Global exception handling is implemented to capture and return JSON error responses.