This example shows how to use Flask 2 on Vercel with Serverless Functions using the Python Runtime.
https://flask-python-template.vercel.app/
This example uses the Web Server Gateway Interface (WSGI) with Flask to enable handling requests on Vercel with Serverless Functions.
npm i -g vercel
vercel dev
Your Flask application is now available at http://localhost:3000
.
Deploy the example using Vercel:
https://py-pwdgenchecker.vercel.app/pwd-generator
https://py-pwdgenchecker.vercel.app/pwd-strength
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
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