diff --git a/utils/app.py b/utils/app.py index 02fa1de..c7aa23e 100644 --- a/utils/app.py +++ b/utils/app.py @@ -58,5 +58,14 @@ def case(): def about(): 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) diff --git a/utils/generate.py b/utils/generate.py index 9ed7fc5..b666829 100644 --- a/utils/generate.py +++ b/utils/generate.py @@ -27,4 +27,10 @@ def lowercase(input): def uppercase(input): output = input.upper() - return output \ No newline at end of file + return output + +def random_num(min, max): + min = int(min) + max = int(max) + output = randint(min, max) + return output diff --git a/utils/templates/index.j2 b/utils/templates/index.j2 index c616b1e..47c4be9 100644 --- a/utils/templates/index.j2 +++ b/utils/templates/index.j2 @@ -21,6 +21,12 @@ Text casing +

Numbers

+