import os
from fastapi import FastAPI, HTTPException
from fastapi.responses import HTMLResponse
from random import choice
import logging

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.WARNING)

app = FastAPI()

# Updated list of quotes provided by the builder
quotes = [
    "When you have a dream, you've got to grab it and never let go - Carol Burnett",
    "Nothing is impossible. The word itself says 'I'm possible!' - Audrey Hepburn",
    "There is nothing impossible to they who will try. - Alexander the Great",
    "The bad news is time flies. The good news is you're the pilot. - Michael Altshuler",
    "Life has got all those twists and turns. You've got to hold on tight and off you go. - Nicole Kidman",
    "Keep your face always toward the sunshine, and shadows will fall behind you. - Walt Whitman",
    "Be courageous. Challenge orthodoxy. Stand up for what you believe in. When you are in your rocking chair talking to your grandchildren many years from now, be sure you have a good story to tell. - Amal Clooney",
    "You make a choice: continue living your life feeling muddled in this abyss of self-misunderstanding, or you find your identity independent of it. You draw your own box. - Duchess Meghan",
    "I just want you to know that if you are out there and you are being really hard on yourself right now for something that has happened ... it's normal. That is what is going to happen to you in life. No one gets through unscathed. We are all going to have a few scratches on us. Please be kind to yourselves and stand up for yourself, please. - Taylor Swift",
    "Success is not final, failure is not fatal: it is the courage to continue that counts. - Winston Churchill",
    "You define your own life. Don't let other people write your script. - Oprah Winfrey",

About this template

A random quote generator app with an enticing colour theme

Introduction to the BlendQuote Template

Welcome to the BlendQuote template, a Lazy template designed to help you create a random quote generator app with an appealing color theme. This app uses FastAPI to serve a web interface where users can click to receive a random inspirational quote displayed in a random font. The app also provides an API endpoint to fetch a random quote programmatically.

Getting Started with the BlendQuote Template

To begin building your random quote generator app using the BlendQuote template, simply click on "Start with this Template" in the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.

Test: Deploying the App

Once you have started with the template, the next step is to deploy your app. Press the "Test" button to initiate the deployment process. The Lazy CLI will handle the deployment, and you won't need to install any libraries or set up your environment, as Lazy takes care of all of that for you.

Using the BlendQuote App

After pressing the "Test" button and the deployment is complete, Lazy will provide you with a dedicated server link. You can use this link to access the web interface of your app. The main page will display a message inviting users to click to get their quote. Upon clicking, a random quote along with a random font will be displayed.

If you want to interact with the app programmatically, you can use the provided API endpoint /get_quote. Lazy will also provide a link to the FastAPI documentation, where you can see all available API endpoints and their details.

Here's a sample request to the API:

GET /get_quote

And a sample response might look like this:

{
    "quote": "Life has got all those twists and turns. You've got to hold on tight and off you go. - Nicole Kidman",
    "font": "Times New Roman"
}

Integrating the BlendQuote App

If you wish to integrate the BlendQuote app into another service or frontend, you can use the server link provided by Lazy to make API calls from your external tool. For example, if you have a website and want to display a random quote, you can make an AJAX call to the /get_quote endpoint and display the result on your site.

Here's an example of how you might integrate the API into an external website:

fetch('YOUR_SERVER_LINK/get_quote')
    .then(response => response.json())
    .then(data => {
        // Use data.quote and data.font to display the quote in your website's UI
    })
    .catch(error => console.error('Error fetching the quote:', error));

Replace YOUR_SERVER_LINK with the actual server link provided by Lazy after deployment.

By following these steps, you can easily use the BlendQuote template to create and deploy a random quote generator app on the Lazy platform without worrying about the technical details of deployment and environment setup.

Category
Technology
Last published
May 18, 2024

More templates like this

Home
/
BlendQuote