-
Notifications
You must be signed in to change notification settings - Fork 12
/
app.py
130 lines (103 loc) · 4.87 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import os
import sys
import json
from datetime import datetime
import requests
from flask import Flask ,render_template, redirect, url_for, session, request, logging
app = Flask(__name__)
@app.route('/accept/<string:timeindex>',methods=['GET','POST'])
def accept(timeindex):
print(timeindex)
timeindexlist = timeindex.split('&')
if timeindexlist[1] == 'null':
return redirect(url_for('home'))
url = 'https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/webapp/accepted'
data = {'TimeIndex':timeindexlist[0],'AcceptedBy':timeindexlist[1]}
headers = {'content-type': 'application/json'}
r=requests.post(url, data=json.dumps(data), headers=headers)
data = r.json()
return redirect(url_for('home'))
@app.route('/kerala', methods=['GET','POST']) #landing page
def home1():
if request.method == 'POST':
keyword1 = request.form['data']
url = 'https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/webapp/district'
data = {'keyword':keyword1}
headers = {'content-type': 'application/json'}
r=requests.post(url, data=json.dumps(data), headers=headers)
data = r.json()
request_no = data['Count']
return render_template("index.html",requestnumber = request_no, data = data, district = keyword1)
r = requests.get('https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/androidapp/get')
data = r.json()
request_no = data['Count']
return render_template("index.html",requestnumber = request_no, data = data)
@app.route('/', methods=['GET','POST']) #landing page
def home():
if request.method == 'POST':
keyword1 = request.form['data']
url = 'https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/webapp/district'
data = {'keyword':keyword1}
headers = {'content-type': 'application/json'}
r=requests.post(url, data=json.dumps(data), headers=headers)
data = r.json()
request_no = data['Count']
return render_template("index.html",requestnumber = request_no, data = data, district = keyword1)
r = requests.get('https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/androidapp/get')
data = r.json()
request_no = data['Count']
return render_template("index.html",requestnumber = request_no, data = data)
@app.context_processor
def date_processor():
def change_epoch(epoch):
ts = int(epoch)
ts = ts/1000
return datetime.fromtimestamp(ts).strftime('%Y-%m-%d %I:%M %p')
return dict(change_epoch=change_epoch)
@app.route('/disclaimer', methods=['GET','POST']) #landing page
def disclaimer():
return render_template("disclaimer.html")
@app.route('/moderator', methods=['GET','POST']) #landing page
def moderator():
if request.method == 'POST':
keyword1 = request.form['data']
url = 'https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/webapp/district'
data = {'keyword':keyword1}
headers = {'content-type': 'application/json'}
r=requests.post(url, data=json.dumps(data), headers=headers)
data = r.json()
request_no = data['Count']
return render_template("moderate.html",requestnumber = request_no, data = data, district = keyword1)
r = requests.get('https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/androidapp/get')
data = r.json()
request_no = data['Count']
return render_template("moderate.html",requestnumber = request_no, data = data)
@app.route('/moderatorcomment/<string:timeindex>',methods=['GET','POST'])
def remark(timeindex):
print(timeindex)
timeindexlist = timeindex.split('&')
if timeindexlist[1] == 'null':
return redirect(url_for('moderator'))
url = 'https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/webapp/current-info-update'
data = {'TimeIndex':timeindexlist[0],'Current_Info':timeindexlist[1]}
headers = {'content-type': 'application/json'}
r=requests.post(url, data=json.dumps(data), headers=headers)
data = r.json()
return redirect(url_for('moderator'))
@app.route('/moderatordelete/<string:timeindex>',methods=['GET','POST'])
def delete(timeindex):
print(timeindex)
url = 'https://byw1s98hik.execute-api.ap-south-1.amazonaws.com/dev/androidapp/remove-request-from-timeindex'
data = {'TimeIndex':timeindex}
headers = {'content-type': 'application/json'}
r=requests.post(url, data=json.dumps(data), headers=headers)
return redirect(url_for('moderator'))
@app.context_processor
def date_processor():
def change_epoch(epoch):
ts = int(epoch)
ts = ts/1000
return datetime.fromtimestamp(ts).strftime('%Y-%m-%d %I:%M %p')
return dict(change_epoch=change_epoch)
if __name__=='__main__':
app.run(threaded=True,host="0.0.0.0",port=80) #Debugger is set to 1 for testing and overriding the default port to http port