get ready for another util

This commit is contained in:
Nyx 2025-03-22 12:09:42 -05:00
parent 604afbeb9a
commit b9fe8b8baa
4 changed files with 48 additions and 20 deletions

View file

@ -13,17 +13,24 @@ app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
return render_template('index.j2')
@app.route('/ip6-gen', methods=['GET', 'POST'])
def ip6gen():
if request.method == 'POST':
subnet = request.form['subnet']
ip = generate.generate_ip(subnet)
return redirect(url_for('result', ip=ip))
return render_template('index.j2')
type = "IPv6 generator"
return redirect(url_for('result', result=ip, type=type))
return render_template('ip6-gen.j2')
@app.route('/result')
def result():
ip = request.args.get('ip')
ip = sanitize_html(ip)
return render_template('result.j2', result=ip)
result = request.args.get('result')
type = request.args.get('type')
result = sanitize_html(result)
type = sanitize_html(type)
return render_template('result.j2', result=result, type=type)
@app.route('/assets/style.css')
def css():

View file

@ -5,11 +5,12 @@
<link href="assets/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>IPv6 generator</h1>
<form method="POST">
<input type="text" name="subnet" size="10" placeholder="IPv6 subnet" />
<button type="submit">generate</button>
</form>
<h1>Utilites</h1>
<ul>
<li>
<a href="ip6-gen">IPv6 generator</a>
</li>
</ul>
<footer>
<hr />
<a href="https://git.everypizza.im/n/utils">source code</a> | version 0.0.1

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<title>Utilities</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>IPv6 generator</h1>
<form method="POST">
<input type="text" name="subnet" size="10" placeholder="IPv6 subnet" />
<button type="submit">generate</button>
</form>
<footer>
<hr />
<a href="/">← back home</a>
<a href="https://git.everypizza.im/n/utils">source code</a> | version 0.0.1
</footer>
</body>
</html>

View file

@ -5,7 +5,7 @@
<link href="assets/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Result for {{ action }}</h1>
<h1>Result for {{ type }}</h1>
<p>
{{ result }}
</p>