Compare commits
2 commits
628b4c0148
...
c7f41c7fa5
Author | SHA1 | Date | |
---|---|---|---|
c7f41c7fa5 | |||
bd19da9792 |
4 changed files with 44 additions and 2 deletions
11
utils/app.py
11
utils/app.py
|
@ -56,7 +56,16 @@ def case():
|
|||
|
||||
@app.route('/about')
|
||||
def about():
|
||||
return send_from_directory('static', 'about.sanitize_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__':
|
||||
app.run(debug=True)
|
||||
|
|
|
@ -27,4 +27,10 @@ def lowercase(input):
|
|||
|
||||
def uppercase(input):
|
||||
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>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Numbers</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href='rand'>Random number</a>
|
||||
</li>
|
||||
</ul>
|
||||
<footer>
|
||||
<hr />
|
||||
<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