feat: random number generator
This commit is contained in:
parent
bd19da9792
commit
c7f41c7fa5
4 changed files with 43 additions and 1 deletions
|
@ -58,5 +58,14 @@ def case():
|
||||||
def about():
|
def about():
|
||||||
return send_from_directory('static', 'about.html')
|
return send_from_directory('static', 'about.html')
|
||||||
|
|
||||||
|
@app.route('/rand', methods=['GET', 'POST'])
|
||||||
|
def rand():
|
||||||
|
if request.method == 'POST':
|
||||||
|
min = request.form['min']
|
||||||
|
max = request.form['max']
|
||||||
|
result = str(generate.random_num(min, max))
|
||||||
|
return redirect(url_for('result', result=result, type='random number'))
|
||||||
|
return render_template('random.j2')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|
|
@ -28,3 +28,9 @@ def lowercase(input):
|
||||||
def uppercase(input):
|
def uppercase(input):
|
||||||
output = input.upper()
|
output = input.upper()
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
def random_num(min, max):
|
||||||
|
min = int(min)
|
||||||
|
max = int(max)
|
||||||
|
output = randint(min, max)
|
||||||
|
return output
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
<a href="case">Text casing</a>
|
<a href="case">Text casing</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<h3>Numbers</h3>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href='rand'>Random number</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
<footer>
|
<footer>
|
||||||
<hr />
|
<hr />
|
||||||
<a href="https://git.everypizza.im/n/utils">source code</a> | version 0.0.1 |
|
<a href="https://git.everypizza.im/n/utils">source code</a> | version 0.0.1 |
|
||||||
|
|
21
utils/templates/random.j2
Normal file
21
utils/templates/random.j2
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!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>Random number generator</h1>
|
||||||
|
<form method="POST">
|
||||||
|
<input type="text" name="min" size="3" placeholder="1" />
|
||||||
|
<input type="text" name="max" size="3" placeholder="100">
|
||||||
|
<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>
|
Loading…
Add table
Reference in a new issue