Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
i0Ek3 committed Jan 21, 2024
1 parent 8cb5494 commit 0b2c9c8
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# rpg

Random Password Generator written by Poe(GPT-3.5).

## Run

```Python
$ python3 app.py # then open the link: http://127.0.0.1:5000
```
30 changes: 30 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flask import Flask, render_template, request
import random
import string

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) # 确保密码不以特殊字符结尾
return password

def genpwd2():
password = ''
for _ in range(3):
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'])
def home():
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')

if __name__ == '__main__':
app.run()
Binary file added rpg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<title>RPG: Random Password Generator</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f2f2f2;
flex-direction: column;
}

button {
align-self: center;
color: rgb(41, 157, 66);
font-size: 24px;
margin-bottom: 20px;
width: 150px;
height: 50px;
border-radius: 25px;
border: none;
background-color: rgb(41, 157, 66);
color: white;
cursor: pointer;
}

p {
align-self: center;
font-family: "Ubuntu", sans-serif;
font-size: 30px;
color: black;
}
</style>
</head>
<body>
<form action="/" method="POST">
<button type="submit">Generate</button>
</form>
{% if password %}
<p>{{ password }}</p>
{% endif %}
{% if password2 %}
<p>{{ password2 }}</p>
{% endif %}
</body>
</html>

0 comments on commit 0b2c9c8

Please sign in to comment.