forked from philson-philip/keralarescue
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
73 lines (58 loc) · 2.7 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
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)
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