v1 complete
Browse files- Dockerfile +15 -0
- app.py +29 -0
- templates/index.html +15 -0
Dockerfile
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.12
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
RUN pip install --no-cache-dir flask
|
11 |
+
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
15 |
+
|
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, render_template
|
2 |
+
from markupsafe import Markup
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
@app.route('/', methods=['POST', 'GET'])
|
6 |
+
def index():
|
7 |
+
if request.method == 'POST':
|
8 |
+
# opt= passgenm(request.form['len'], request.form['num'])
|
9 |
+
opt= passgen(request.form['len'])
|
10 |
+
return render_template('result.html', result=Markup(opt))
|
11 |
+
else:
|
12 |
+
return render_template('index.html')
|
13 |
+
|
14 |
+
|
15 |
+
def passgenm(length,number):
|
16 |
+
opt=""
|
17 |
+
for i in range(int(number)):
|
18 |
+
opt+=passgen(length)+"<br>\n"
|
19 |
+
return opt
|
20 |
+
|
21 |
+
def passgen(length):
|
22 |
+
import random
|
23 |
+
import string
|
24 |
+
length = int(length)
|
25 |
+
password = ''
|
26 |
+
for i in range(length):
|
27 |
+
password += random.choice(string.ascii_letters + string.digits + string.punctuation)
|
28 |
+
return password
|
29 |
+
|
templates/index.html
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head><title>passgen</title></head>
|
3 |
+
<body>
|
4 |
+
<h1>passgen</h1>
|
5 |
+
<p>Generate a random password:</p>
|
6 |
+
<form action="/" method="post">
|
7 |
+
<label for="len">Length:</label>
|
8 |
+
<input type="number" name="len" id="len" value="16" min="10" max="100">
|
9 |
+
<label for="num">number of passwords:</label>
|
10 |
+
<input type="number" name="num" id="num" value="1" min="1" max="100">
|
11 |
+
<input type="submit" value="Generate">
|
12 |
+
</form>
|
13 |
+
</body>
|
14 |
+
</html>
|
15 |
+
|