Skip to content

rlanier-webdev/pwgenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Password Generator API

Overview

This project provides a simple web server with an endpoint to generate random passwords. It uses the Gin framework for handling HTTP requests and serves both HTML and API responses.

Features

  • Web Interface: Displays a page with a randomly generated password.
  • API Endpoint: Provides an endpoint to generate and return a password in JSON format.

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/rlanier-webdev/pwgenerator.git
    cd pwgenerator
  2. Install dependencies:

    go mod tidy
  3. Run the application:

    go run main.go

    The server will start and listen on port 8080.

Endpoints

  • Web Interface

    • URL: http://localhost:8080/
    • Method: GET
    • Description: Serves an HTML page with a randomly generated password.
  • API Endpoint

    • URL: http://localhost:8080/api/password
    • Method: GET
    • Description: Returns a JSON object with a randomly generated password.

    Response Example:

    {
        "password": "GeneratedPasswordHere"
    }

Code Structure

  • main.go: Contains the main application logic and routes. Includes password generation functions and API route definitions.
  • handler.go: Defines the handler for the web interface.