-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
51 lines (37 loc) · 1.14 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
from flask import Flask, request, jsonify
from adapter import Adapter
from tweetAdapter import tweetAdapter
from getRecentTweet import getRecentTweet
app = Flask(__name__)
@app.before_request
def log_request_info():
app.logger.debug('Headers: %s', request.headers)
app.logger.debug('Body: %s', request.get_data())
@app.route('/price', methods=['POST'])
def call_adapter():
data = request.get_json()
if data == '':
data = {}
adapter = Adapter(data)
return jsonify(adapter.result)
@app.route('/grabTweet', methods=['POST'])
def call_tweet_adapter():
data = request.get_json()
if data == '':
data = {}
adapter = tweetAdapter(data)
adapter.grabTweet()
return jsonify(adapter.result)
@app.route('/grabRecent', methods=['POST'])
def call_recent_tweet_adapter():
data = request.get_json()
if data == '':
data = {}
adapter = getRecentTweet(data)
adapter.grabRecent()
return jsonify(adapter.result)
@app.route('/test', methods=['GET'])
def tester():
return jsonify("hello")
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port='8080', threaded=True)