From 1e70473250145517b5d651139c397ece55edd2a0 Mon Sep 17 00:00:00 2001 From: Josh Mudge Date: Fri, 15 Mar 2019 19:01:34 -0600 Subject: [PATCH] Move Caeser, add Flask setup with Caeser-cipher. --- .../Caeser-Cipher/Caeser-Cipher.py | 4 ++-- .../Caeser-Cipher}/README.md | 0 Web/app.py | 20 +++++++++++++++++++ Web/templates/my-form.html | 12 +++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) rename Caeser-Cipher/caeser-cipher.py => Web/Caeser-Cipher/Caeser-Cipher.py (97%) rename {Caeser-Cipher => Web/Caeser-Cipher}/README.md (100%) create mode 100644 Web/app.py create mode 100644 Web/templates/my-form.html diff --git a/Caeser-Cipher/caeser-cipher.py b/Web/Caeser-Cipher/Caeser-Cipher.py similarity index 97% rename from Caeser-Cipher/caeser-cipher.py rename to Web/Caeser-Cipher/Caeser-Cipher.py index cec75ba..2147767 100644 --- a/Caeser-Cipher/caeser-cipher.py +++ b/Web/Caeser-Cipher/Caeser-Cipher.py @@ -46,7 +46,7 @@ def encrypt(ciphertext, shiftNum, letters): # Grab parameters letterCount = letterCount + 1 # Keep track of how many times we're doing this. - print("\nYour enciphered text is: " + answer) + return print("\nYour enciphered text is: " + answer) def decrypt(ciphertext, shiftNum, letters): # Grab parameters @@ -77,7 +77,7 @@ def decrypt(ciphertext, shiftNum, letters): # Grab parameters letterCount = letterCount + 1 # Keep track of how many times we're doing this. - print("\nYour decrypted text is: " + answer) + return print("\nYour decrypted text is: " + answer) def freq(ciphertext): diff --git a/Caeser-Cipher/README.md b/Web/Caeser-Cipher/README.md similarity index 100% rename from Caeser-Cipher/README.md rename to Web/Caeser-Cipher/README.md diff --git a/Web/app.py b/Web/app.py new file mode 100644 index 0000000..060bce3 --- /dev/null +++ b/Web/app.py @@ -0,0 +1,20 @@ +#!flask/bin/python +from flask import Flask, request, render_template +import os +import subprocess + +app = Flask(__name__) + +@app.route('/') +def my_form(): + return render_template('my-form.html') + +@app.route('/', methods=['POST']) +def form_post(): + text = request.form['secret'] + command = "python3 Caeser-Cipher/Caeser-Cipher.py encrypt " + str(text) + " 3" + ciphered_text = subprocess.check_output(command, shell=True) + return ciphered_text + +if __name__ == '__main__': + app.run(debug=True) diff --git a/Web/templates/my-form.html b/Web/templates/my-form.html new file mode 100644 index 0000000..e5e15c9 --- /dev/null +++ b/Web/templates/my-form.html @@ -0,0 +1,12 @@ +
+

Enter your message in this box.

+
+ + +
+