Set of services for extracting metadata from emails and taking an action on it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1.1 KiB

import os
import sys
import flask
import requests
app = flask.Flask(__name__)
app.config['DEBUG'] = True
indexer_url = os.environ.get('INDEXER_URL', 'http://indexer')
@app.route('/healthcheck')
def healthcheck():
return 'OK'
@app.route('/')
def home():
return flask.render_template('home.html')
@app.route('/shipping')
def get_tokens():
resp = requests.get(
indexer_url+'/token',
params={
'filter_type': 'SHIPPING',
'desc': True,
},
)
resp.raise_for_status()
tokens = resp.json().get('tokens')
for token in tokens:
try:
resp = requests.get(
'http://viewer_package_tracking:3000/info/'+token['token']
)
resp.raise_for_status()
print('Response: ', resp.text, file=sys.stderr)
info = resp.json()
token['metadata'].update(info)
except Exception as e:
print('Error', e, file=sys.stderr)
pass
return flask.render_template('shipping.html', trackers=tokens)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)