by Lazy Sloth
AI Image Slideshow Generator
import os
import json
from fastapi import FastAPI, Form, HTTPException
from fastapi.responses import HTMLResponse, RedirectResponse
from abilities import get_ai_generated_image_url, llm_prompt, upload_file_to_storage
from io import BytesIO
import zipfile
import requests
from PIL import Image
import logging
logger = logging.getLogger("uvicorn")
logging.basicConfig(level=logging.INFO)
app = FastAPI()
@app.get("/", response_class=HTMLResponse)
async def read_root():
# Serve the HTML content directly without using a file
html_content = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
Created: | Last Updated:
Introduction to the AI Image Slideshow Generator Template
Welcome to the AI Image Slideshow Generator template! This template is designed to help you create a slideshow of images generated from key points within a block of text. The app uses AI to identify the key moments in your story and then automatically generates an image for each moment. This is perfect for visualizing stories, creating presentations, or just having fun with AI-generated art.
Getting Started
To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will set up the template in your Lazy Builder interface, and you'll be ready to customize and deploy your app.
Initial Setup
There are no environment secrets to set up for this template, so you can move straight to testing and using your app.
Test: Deploying the App
Once you have the template open in the Lazy Builder, press the "Test" button. This will begin the deployment of your app and launch the Lazy CLI. The CLI will handle the deployment process, and you won't need to worry about installing libraries or setting up your environment.
Entering Input
After pressing the "Test" button and once the app is deployed, the Lazy CLI will prompt you for any required user input. For this template, you will be asked to enter the text for your story. This text will be used by the AI to identify key moments and generate corresponding images.
Using the App
Once your app is deployed and running, you can interact with it through a web interface. You'll be provided with a dedicated server link to use the API. If you're using FastAPI, you'll also receive a link to the API documentation. Simply navigate to the provided link to access the Slideshow Generator's web form, where you can enter your story and generate your slideshow.
Integrating the App
If you wish to integrate the slideshow generator into another service or frontend, you can use the server link provided by Lazy. This link can be added to external tools that support API requests. For example, if you're integrating with a web application, you can send POST requests to the "/generate_slideshow" endpoint with the story as form data.
Here's a sample request you might use in an external tool:
POST /generate_slideshow HTTP/1.1<br>
Host: [Your Lazy Server Link]<br>
Content-Type: application/x-www-form-urlencoded<br>
<br>
story=Your+story+text+goes+here...
And a sample response might look like this:
HTTP/1.1 303 See Other<br>
Location: /success?zip_file_url=[URL to the ZIP file of images]
Remember, the actual server link and the URL to the ZIP file will be provided by the Lazy platform after you press the "Test" button.
That's it! You're now ready to use the AI Image Slideshow Generator template to create engaging visual stories. Enjoy exploring the capabilities of AI with Lazy!