add `debug=True` in consumer
[doctor.git] / tests / consumer.py
1 ##############################################################################
2 # Copyright (c) 2016 NEC Corporation and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 import argparse
11 from flask import Flask
12 from flask import request
13 import json
14 import os
15 import time
16
17
18 app = Flask(__name__)
19
20
21 @app.route('/failure', methods=['POST'])
22 def event_posted():
23     app.logger.debug('doctor consumer notified at %s' % time.time())
24     app.logger.debug('received data = %s' % request.data)
25     d = json.loads(request.data)
26     return "OK"
27
28
29 def get_args():
30     parser = argparse.ArgumentParser(description='Doctor Sample Consumer')
31     parser.add_argument('port', metavar='PORT', type=int, nargs='?',
32                         help='the port for consumer')
33     return parser.parse_args()
34
35
36 def main():
37     args = get_args()
38     app.run(host="0.0.0.0", port=args.port, debug=True)
39
40
41 if __name__ == '__main__':
42     main()