Skip to content

Commit

Permalink
style: 'black' the code style
Browse files Browse the repository at this point in the history
  • Loading branch information
i0Ek3 committed Feb 18, 2024
1 parent 6ba4aa1 commit f75686c
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,37 @@

app = Flask(__name__)


def genpwd(length):
characters = string.ascii_letters + string.digits + '!@#$%&*-'
password = random.choice(string.ascii_letters + string.digits) # 确保密码不以特殊字符开头
password += ''.join(random.choice(characters) for _ in range(length - 2))
password += random.choice(string.ascii_letters + string.digits) # 确保密码不以特殊字符结尾
characters = string.ascii_letters + string.digits + "!@#$%&*-"
password = random.choice(
string.ascii_letters + string.digits
) # 确保密码不以特殊字符开头
password += "".join(random.choice(characters) for _ in range(length - 2))
password += random.choice(
string.ascii_letters + string.digits
) # 确保密码不以特殊字符结尾
return password


def genpwd2():
password = ''
password = ""
for _ in range(3):
segment = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(4))
password += segment + '-'
segment = "".join(
random.choice(string.ascii_letters + string.digits) for _ in range(4)
)
password += segment + "-"
password = password[:-1] # 移除末尾的连接符-
return password

@app.route('/', methods=['GET', 'POST'])

@app.route("/", methods=["GET", "POST"])
def home():
if request.method == 'POST':
if request.method == "POST":
pwda, pwdb = genpwd2(), genpwd(random.randint(8, 12))
return render_template('index.html', password=pwda, password2=pwdb)
return render_template('index.html')
return render_template("index.html", password=pwda, password2=pwdb)
return render_template("index.html")


if __name__ == '__main__':
app.run()
if __name__ == "__main__":
app.run()

0 comments on commit f75686c

Please sign in to comment.