-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.py
More file actions
63 lines (47 loc) · 1.8 KB
/
index.py
File metadata and controls
63 lines (47 loc) · 1.8 KB
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
57
58
59
60
61
62
63
from flask import Flask, jsonify, request, render_template
from flask_cors import CORS
nature_emojis = [
'🐆','🐴','🫎','🫏','🍂','🌺',
'🍀','🍁','🍄','🌹','🌲','🌴',
'🍅','🍆','🌽','🍊','🍎','🍓',
'🍐','🍏','🌟','⛅','🌈','🍑',
'🍍','🍌',
'🍉','🦌','🦬','🐮','🐂','🐄',
'🐷','🐩','🐺','🦊','🐱','🐈',
'🍃','🌸','🦄','🦓','🍇','🍈',
'🐯','🐅','🌿','🌻','🪵','🌳',
'🐍','💐','🦋','🐼','🌾','💧',
'⚡','🪷',
'🐔'
# 🐆🐴🫎🫏🍂🌺🍀🍁🍄🌹🌲🌴🍅🍆🌽🍊🍎🍓🍐🍏🌟⛅🌈🍑🍍🍌🍉🦌🦬🐮🐂🐄🐷🐩🐺🦊🐱🐈🍃🌸🦄🦓🍇🍈🐯🐅🌿🌻🪵🌳🐍💐🦋🐼🌾💧⚡🪷
]
N = len(nature_emojis)
app = Flask(__name__)
CORS(app, resources={r"/encrypt": {"origins": "*"}})
CORS(app, resources={r"/decrypt": {"origins": "*"}})
@app.route('/')
def index():
return render_template('index.html')
@app.route('/encrypt', methods=['POST'])
def encrypt_text():
try:
data = request.get_json()
modified_text = ''
for i in data:
modified_text += nature_emojis[(ord(i) - ord('A'))]
return jsonify({'modified_text': modified_text})
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/decrypt', methods=['POST'])
def decrypt_text():
try:
data = request.get_json()
modified_text = ''
for i in data:
modified_text += chr(nature_emojis.index(i) + 65)
return jsonify({'modified_text': modified_text})
except Exception as e:
# print(e)
return jsonify({'error': str(e)}), 500
if __name__ == '__main__':
app.run(debug=True)