-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
64 lines (50 loc) · 1.44 KB
/
app.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
57
58
59
60
61
62
import email
import imaplib
from flask import Flask, request, jsonify, make_response
from utils import login, goRefresh, s3_transfer
from termcolor import colored
app = Flask(__name__)
print(s3_transfer.bucketExist())
#
# def print_hi(name):
# # Use a breakpoint in the code line below to debug your script.
# print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
#
@app.route('/api/v1/newMails')
def newMails():
print(colored("Entered newMails", 'green'))
con = login.Login()
con.select('GRX')
typ, data = con.search(None, 'ALL')
# closing connection
con.close()
if data == [b'']:
return "False"
print("there are new masils -> ", data)
return 'True'
@app.route('/api/v1/saveMails', methods=['POST'])
def saveMails():
print("entered saveMails")
s3_transfer.transfer()
response = make_response(
'sababa',
200,
)
response.headers["Content-Type"] = "application/json"
return response
@app.route('/api/v1/refresh')
def refresh():
actions, unKnownActions = goRefresh.GoRefresh()
body = {'actions': actions, 'unKnownActions': unKnownActions}
response = make_response(
jsonify(body),
200,
)
response.headers["Content-Type"] = "application/json"
return response
@app.route('/')
def index():
return "Shalom :2)"
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
app.run(debug=True)