Random Name Generator

 
from flask import Flask, render_template, jsonify
import random

app = Flask(__name__)

first_names = ["James", "Robert", "Ryan", "Ashley", "Jane", "Hannah"]
last_names = ["Elsher", "Whiteton", "Brigerton", "James", "Bond", "Mathew"]

@app.route("/")
def root_route():
    return render_template('template.html')

@app.route("/generate-name")
def generate_name():
    return jsonify(name=f"{random.choice(first_names)} {random.choice(last_names)}")

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

About this template

A web app that generates random first and last names with a visually appealing design.

Introduction to the Random Name Generator Template

Welcome to the Random Name Generator template! This template is designed to help you create a web application that generates random names at the click of a button. With a visually appealing design, this app is perfect for anyone looking to add a name generation feature to their project without worrying about the complexities of coding and deployment.

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, pre-populating the code so you can start customizing and testing your application right away.

Test: Deploying the App

Once you have the template open in the Lazy Builder, you can deploy your app by pressing the "Test" button. This will launch the Lazy CLI, and the platform will handle the deployment process for you. There's no need to install libraries or set up your environment, as Lazy takes care of all that.

Using the App

After deployment, you will be provided with a dedicated server link to interact with your new Random Name Generator app. Here's how to use the interface:

  • Open the provided server link in your web browser to view the Random Name Generator.
  • You will see a button labeled "Generate Name" on the page.
  • Click the button, and a random name will be displayed on the screen.

The app's frontend is straightforward and user-friendly, ensuring a seamless experience for all users.

Integrating the App

If you wish to integrate the Random Name Generator into another service or frontend, you can use the provided server link as an API endpoint. Here's a sample request you might use to interact with the app programmatically:


fetch('YOUR_SERVER_LINK/generate-name')
  .then(response => response.json())
  .then(data => console.log(data.name));

Replace 'YOUR_SERVER_LINK' with the actual link provided after deployment. The response will be a JSON object containing the generated name, which you can then use in your application.

If you need to integrate this app into an external tool that requires the API endpoint, simply add the server link to the tool's configuration where API requests are made.

That's all there is to it! With these simple steps, you can have your Random Name Generator up and running, and easily integrate it into your projects using the Lazy platform.

Category
Technology
Last published
May 18, 2024

More templates like this

Home
/
Random Name Generator