/py_pwdgenchecker

Generates secure passwords of custom length, combining uppercase letters, lowercase letters, numbers and special symbols. The user can specify the length of the password and choose whether or not to include certain types of characters. In addition, you can add a function to evaluate the strength of a password entered by the user.

Primary LanguagePython

Deploy with Vercel

Flask + Vercel

This example shows how to use Flask 2 on Vercel with Serverless Functions using the Python Runtime.

Demo

https://flask-python-template.vercel.app/

How it Works

This example uses the Web Server Gateway Interface (WSGI) with Flask to enable handling requests on Vercel with Serverless Functions.

Running Locally

npm i -g vercel
vercel dev

Your Flask application is now available at http://localhost:3000.

One-Click Deploy

Deploy the example using Vercel:

Deploy with Vercel

REST API

Generate secure passwords

https://py-pwdgenchecker.vercel.app/pwd-generator

Check the Passwords strength

https://py-pwdgenchecker.vercel.app/pwd-strength

Functions

Generate secure passwords

def generate_password(length, include_uppercase, include_digits, include_special_chars):
    character_set = string.ascii_lowercase
    if include_uppercase:
        character_set += string.ascii_uppercase
    if include_digits:
        character_set += string.digits
    if include_special_chars:
        character_set += string.punctuation

    password = ''.join(random.choice(character_set) for _ in range(length))
    return password

Check the Password Strength

def password_strength(password):
    has_lowercase = any(c in string.ascii_lowercase for c in password)
    has_uppercase = any(c in string.ascii_uppercase for c in password)
    has_digit = any(c in string.digits for c in password)
    has_special_char = any(c in string.punctuation for c in password)

    strength = 0
    if has_lowercase:
        strength += 1
    if has_uppercase:
        strength += 1
    if has_digit:
        strength += 1
    if has_special_char:
        strength += 1

    return strength