-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
57 lines (50 loc) · 1.25 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from flask import Flask, request
from caesar import rotate_string
app = Flask(__name__)
app.config['DEBUG'] = True
style_form = """
<!DOCTYPE html>
<html lang = "en">
<html>
<head>
<style>
form {{
background-color: #eee;
padding: 20px;
margin: 0 auto;
width: 540px;
font: 16px sans-serif;
border-radius: 10px;
}}
textarea {{
margin: 10px 0;
width: 540px;
height: 120px;
}}
</style>
</head>
</html>
<body>
"""
caesar_form = """
<form action="/caesar", method="post">
<label for="rot">
Rotated by:
<input type ="text" name ="rot" value = "0">
</label>
</br>
<textarea name ="text">{0}</textarea>
<input type="submit" value ="Submit Query">
</form>
</body>
"""
@app.route("/")
def index():
return caesar_form.format("")
@app.route("/caesar", methods=['POST'])
def encrypt():
input_mess = request.form['text']
number_input = request.form['rot']
encrypted_mess = rotate_string(str(input_mess),int(number_input))
return caesar_form.format(encrypted_mess)
app.run()