from flask import Flask, render_template, request
import os
from abilities import llm_prompt

app = Flask(__name__)

def home():
    return render_template('index.html')

@app.route('/generate', methods=['POST'])
def generate_username():
    prompt = "Generate a unique and memorable username."
    model = "gpt-4-1106-preview"  # Using GPT-4 for high quality results
    temperature = 0.5  # A balance between randomness and determinism
    username = llm_prompt(prompt, model, temperature)
    return render_template('index.html', username=username)

if __name__ == "__main__":
    app.run(host='', port=8080)

About this template

This app generates unique usernames.

Introduction to the Unique Username Generator Template

Welcome to the Unique Username Generator template! This template is designed to help you quickly set up an application that generates unique and memorable usernames. It's perfect for builders looking to add a username generation feature to their applications without delving into the complexities of coding from scratch.

Getting Started

To begin using this template, simply click on "Start with this Template" in the Lazy Builder interface. This will pre-populate the code in your workspace, so you can start customizing and testing your application right away.

Test: Deploying the App

Once you have started with the template, the next step is to deploy your app to see it in action. Press the "Test" button in the Lazy Builder. This will initiate the deployment process and launch the Lazy CLI. There's no need to worry about installing libraries or setting up your environment; Lazy handles all of that for you.

Using the App

After pressing the "Test" button, Lazy will provide you with a dedicated server link. This is where you can interact with your newly created Username Generator app. Visit the link, and you'll be greeted with a simple web interface that includes a button to generate a username. Click the button, and the app will display a unique username generated by the underlying GPT-4 model.

If you wish to integrate this username generator into another service or frontend, you can use the server link provided by Lazy. For example, you could embed the link in your website or application, allowing users to generate usernames without leaving your platform.

Integrating the App

If you need to integrate the generated usernames into another tool or platform, you can do so by using the API endpoint provided by the Lazy app. For instance, you might want to post the generated usernames to a database or another web service. To achieve this, you can make a POST request to the "/generate" endpoint of your app's server link. Here's a sample request you could use:

POST /generate HTTP/1.1<br>
Host: [Your Lazy App Server Link]<br>
Content-Type: application/x-www-form-urlencoded<br>

And here's an example of what a sample response might look like:

HTTP/1.1 200 OK<br>
Content-Type: text/html; charset=utf-8<br>
Your generated username is: [GeneratedUsername]

Remember, the actual server link and the generated username will be provided by your Lazy app after deployment. Use the server link in your external tool's configuration to make the API calls.

That's all there is to it! With these simple steps, you can have your Unique Username Generator up and running in no time. Enjoy building with Lazy!

Last published
June 15, 2024

More templates like this

PDF Data Extraction and Excel Transfer

An app for extracting name, phone number, and email data from PDF files and transferring it to Excel.


GPT-4 Exam Generator

This app uses GPT-4 to generate a PDF of a new exam based on an uploaded PDF of a past exam.


Job Search Website

A customisable one-page job search website with a search bar and a search button that displays UI cards of matching jobs. You need to have a (free) account on https://rapidapi.com/ to get the API key required for this to work.

React JS